Enforce code formatting via Prettier #44
@ -1,16 +1,16 @@
|
|||||||
package se.su.dsv.scipro.api;
|
package se.su.dsv.scipro.api;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
import java.util.Optional;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
import se.su.dsv.scipro.system.UserService;
|
import se.su.dsv.scipro.system.UserService;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class ApiController {
|
public class ApiController {
|
||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -21,9 +21,9 @@ public class ApiController {
|
|||||||
@GetMapping("/hello-world")
|
@GetMapping("/hello-world")
|
||||||
public String helloWorld(@RequestParam(value = "username", required = false) String username) {
|
public String helloWorld(@RequestParam(value = "username", required = false) String username) {
|
||||||
String name = Optional.ofNullable(username)
|
String name = Optional.ofNullable(username)
|
||||||
.map(userService::findByUsername)
|
.map(userService::findByUsername)
|
||||||
.map(User::getFullName)
|
.map(User::getFullName)
|
||||||
.orElse("World");
|
.orElse("World");
|
||||||
return "Hello, " + name + "!";
|
return "Hello, " + name + "!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -53,8 +53,11 @@ import se.su.dsv.scipro.system.UserRepoImpl;
|
|||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
public class RepositoryConfiguration {
|
public class RepositoryConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public GradingHistoryEventRepositoryImpl gradingHistoryEventRepository(Provider<EntityManager> em) {
|
public GradingHistoryEventRepositoryImpl gradingHistoryEventRepository(
|
||||||
|
Provider<EntityManager> em
|
||||||
|
) {
|
||||||
return new GradingHistoryEventRepositoryImpl(em);
|
return new GradingHistoryEventRepositoryImpl(em);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +67,9 @@ public class RepositoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ActivityFinalSeminarRepositoryImpl activityFinalSeminarRepository(Provider<EntityManager> em) {
|
public ActivityFinalSeminarRepositoryImpl activityFinalSeminarRepository(
|
||||||
|
Provider<EntityManager> em
|
||||||
|
) {
|
||||||
return new ActivityFinalSeminarRepositoryImpl(em);
|
return new ActivityFinalSeminarRepositoryImpl(em);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +109,9 @@ public class RepositoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public FinalSeminarActiveParticipationRepositoryImpl finalSeminarActiveParticipationRepository(Provider<EntityManager> em) {
|
public FinalSeminarActiveParticipationRepositoryImpl finalSeminarActiveParticipationRepository(
|
||||||
|
Provider<EntityManager> em
|
||||||
|
) {
|
||||||
return new FinalSeminarActiveParticipationRepositoryImpl(em);
|
return new FinalSeminarActiveParticipationRepositoryImpl(em);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +151,9 @@ public class RepositoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ForumPostReadStateRepositoryImpl forumPostReadStateRepository(Provider<EntityManager> em) {
|
public ForumPostReadStateRepositoryImpl forumPostReadStateRepository(
|
||||||
|
Provider<EntityManager> em
|
||||||
|
) {
|
||||||
return new ForumPostReadStateRepositoryImpl(em);
|
return new ForumPostReadStateRepositoryImpl(em);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,12 +178,16 @@ public class RepositoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MilestoneActivityTemplateRepositoryImpl milestoneActivityTemplateRepository(Provider<EntityManager> em) {
|
public MilestoneActivityTemplateRepositoryImpl milestoneActivityTemplateRepository(
|
||||||
|
Provider<EntityManager> em
|
||||||
|
) {
|
||||||
return new MilestoneActivityTemplateRepositoryImpl(em);
|
return new MilestoneActivityTemplateRepositoryImpl(em);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public NationalSubjectCategoryRepositoryImpl nationalSubjectCategoryRepository(Provider<EntityManager> em) {
|
public NationalSubjectCategoryRepositoryImpl nationalSubjectCategoryRepository(
|
||||||
|
Provider<EntityManager> em
|
||||||
|
) {
|
||||||
return new NationalSubjectCategoryRepositoryImpl(em);
|
return new NationalSubjectCategoryRepositoryImpl(em);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +227,9 @@ public class RepositoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PublicationMetadataRepositoryImpl publicationMetadataRepository(Provider<EntityManager> em) {
|
public PublicationMetadataRepositoryImpl publicationMetadataRepository(
|
||||||
|
Provider<EntityManager> em
|
||||||
|
) {
|
||||||
return new PublicationMetadataRepositoryImpl(em);
|
return new PublicationMetadataRepositoryImpl(em);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +239,9 @@ public class RepositoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ReviewerDeadlineSettingsRepositoryImpl reviewerDeadlineSettingsRepository(Provider<EntityManager> em) {
|
public ReviewerDeadlineSettingsRepositoryImpl reviewerDeadlineSettingsRepository(
|
||||||
|
Provider<EntityManager> em
|
||||||
|
) {
|
||||||
return new ReviewerDeadlineSettingsRepositoryImpl(em);
|
return new ReviewerDeadlineSettingsRepositoryImpl(em);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +296,9 @@ public class RepositoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SupervisorGradingReportRepositoryImpl supervisorGradingReportRepository(Provider<EntityManager> em) {
|
public SupervisorGradingReportRepositoryImpl supervisorGradingReportRepository(
|
||||||
|
Provider<EntityManager> em
|
||||||
|
) {
|
||||||
return new SupervisorGradingReportRepositoryImpl(em);
|
return new SupervisorGradingReportRepositoryImpl(em);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
public enum Action {
|
public enum Action {
|
||||||
NONE, HAND_IN, PEER, FINAL_THESIS, FINAL_SEMINAR
|
NONE,
|
||||||
|
HAND_IN,
|
||||||
|
PEER,
|
||||||
|
FINAL_THESIS,
|
||||||
|
FINAL_SEMINAR,
|
||||||
}
|
}
|
||||||
|
@ -1,51 +1,48 @@
|
|||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryInit;
|
import com.querydsl.core.annotations.QueryInit;
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
import jakarta.persistence.Basic;
|
||||||
import jakarta.persistence.Table;
|
|
||||||
import jakarta.persistence.Cacheable;
|
import jakarta.persistence.Cacheable;
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.EnumType;
|
import jakarta.persistence.EnumType;
|
||||||
import jakarta.persistence.Enumerated;
|
import jakarta.persistence.Enumerated;
|
||||||
import jakarta.persistence.GenerationType;
|
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToOne;
|
import jakarta.persistence.OneToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
import se.su.dsv.scipro.checklist.Checklist;
|
|
||||||
import se.su.dsv.scipro.file.FileReference;
|
|
||||||
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import se.su.dsv.scipro.checklist.Checklist;
|
||||||
|
import se.su.dsv.scipro.file.FileReference;
|
||||||
|
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "activity")
|
@Table(name = "activity")
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
public class Activity extends LazyDeletableDomainObject {
|
public class Activity extends LazyDeletableDomainObject {
|
||||||
|
|
||||||
public static IActivityPlan builder(){
|
public static IActivityPlan builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
//<editor-fold desc="Basic JPA-mappings">
|
//<editor-fold desc="Basic JPA-mappings">
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "title", nullable=false)
|
@Column(name = "title", nullable = false)
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "date", nullable=false)
|
@Column(name = "date", nullable = false)
|
||||||
private Date date;
|
private Date date;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@ -59,28 +56,31 @@ public class Activity extends LazyDeletableDomainObject {
|
|||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(name = "action")
|
@Column(name = "action")
|
||||||
private Action action = Action.NONE;
|
private Action action = Action.NONE;
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity) referencing other tables.">
|
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity) referencing other tables.">
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
@JoinColumn(name = "activity_plan_id", referencedColumnName = "id")
|
@JoinColumn(name = "activity_plan_id", referencedColumnName = "id")
|
||||||
@QueryInit("project")
|
@QueryInit("project")
|
||||||
private ActivityPlan activityPlan;
|
private ActivityPlan activityPlan;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "checklist_id", referencedColumnName = "id")
|
@JoinColumn(name = "checklist_id", referencedColumnName = "id")
|
||||||
private Checklist checklist;
|
private Checklist checklist;
|
||||||
|
|
||||||
@OneToOne(optional = true, cascade = CascadeType.ALL)
|
@OneToOne(optional = true, cascade = CascadeType.ALL)
|
||||||
@JoinColumn(name = "upload_file_reference_id", referencedColumnName = "id")
|
@JoinColumn(name = "upload_file_reference_id", referencedColumnName = "id")
|
||||||
private FileReference fileUpload;
|
private FileReference fileUpload;
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Constructor">
|
//<editor-fold desc="Constructor">
|
||||||
public Activity() {
|
public Activity() {
|
||||||
this.title = "";
|
this.title = "";
|
||||||
this.description = "";
|
this.description = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Properties (Getters and Setters)">
|
//<editor-fold desc="Properties (Getters and Setters)">
|
||||||
@ -156,6 +156,7 @@ public class Activity extends LazyDeletableDomainObject {
|
|||||||
public void setFileUpload(FileReference fileUpload) {
|
public void setFileUpload(FileReference fileUpload) {
|
||||||
this.fileUpload = fileUpload;
|
this.fileUpload = fileUpload;
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Methods Common To All Objects">
|
//<editor-fold desc="Methods Common To All Objects">
|
||||||
@ -164,8 +165,7 @@ public class Activity extends LazyDeletableDomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof Activity)) return false;
|
if (!(o instanceof Activity)) return false;
|
||||||
final Activity other = (Activity) o;
|
final Activity other = (Activity) o;
|
||||||
return other.canEqual(this)
|
return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
|
||||||
&& Objects.equals(this.getId(), other.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -174,19 +174,22 @@ public class Activity extends LazyDeletableDomainObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString() {
|
||||||
return "Event: "+ getTitle()+"@"+getDate();
|
return "Event: " + getTitle() + "@" + getDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Other methods">
|
//<editor-fold desc="Other methods">
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
return other instanceof Activity;
|
return other instanceof Activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Nested types">
|
//<editor-fold desc="Nested types">
|
||||||
public static class ByDateComparator implements Comparator<Activity>, Serializable {
|
public static class ByDateComparator implements Comparator<Activity>, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Activity o1, Activity o2) {
|
public int compare(Activity o1, Activity o2) {
|
||||||
return o1.getDate().compareTo(o2.getDate());
|
return o1.getDate().compareTo(o2.getDate());
|
||||||
@ -194,6 +197,7 @@ public class Activity extends LazyDeletableDomainObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder implements IActivityPlan, IDate, IName, IDescription, IBuild {
|
public static class Builder implements IActivityPlan, IDate, IName, IDescription, IBuild {
|
||||||
|
|
||||||
private ActivityPlan activityPlan;
|
private ActivityPlan activityPlan;
|
||||||
private Date date;
|
private Date date;
|
||||||
private String name;
|
private String name;
|
||||||
@ -247,7 +251,7 @@ public class Activity extends LazyDeletableDomainObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface IDate {
|
public interface IDate {
|
||||||
IName date (Date date);
|
IName date(Date date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IName {
|
public interface IName {
|
||||||
|
@ -3,10 +3,14 @@ package se.su.dsv.scipro.activityplan;
|
|||||||
import se.su.dsv.scipro.file.FileDescription;
|
import se.su.dsv.scipro.file.FileDescription;
|
||||||
|
|
||||||
public class ActivityFileUploadedEvent {
|
public class ActivityFileUploadedEvent {
|
||||||
|
|
||||||
private final Activity activity;
|
private final Activity activity;
|
||||||
private final FileDescription fileDescription;
|
private final FileDescription fileDescription;
|
||||||
|
|
||||||
public ActivityFileUploadedEvent(final Activity activity, final FileDescription fileDescription) {
|
public ActivityFileUploadedEvent(
|
||||||
|
final Activity activity,
|
||||||
|
final FileDescription fileDescription
|
||||||
|
) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.fileDescription = fileDescription;
|
this.fileDescription = fileDescription;
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,16 @@ import jakarta.persistence.Id;
|
|||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.OneToOne;
|
import jakarta.persistence.OneToOne;
|
||||||
|
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name ="activity_plan")
|
@Table(name = "activity_plan")
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
public class ActivityPlan extends DomainObject {
|
public class ActivityPlan extends DomainObject {
|
||||||
|
|
||||||
@ -31,28 +29,31 @@ public class ActivityPlan extends DomainObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//<editor-fold desc="Basic JPA-mappings">
|
//<editor-fold desc="Basic JPA-mappings">
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "start_date")
|
@Column(name = "start_date")
|
||||||
private Date startDate;
|
private Date startDate;
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan) referencing other tables">
|
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan) referencing other tables">
|
||||||
@OneToOne(optional=false)
|
@OneToOne(optional = false)
|
||||||
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="JPA-mappings of other tables referencing to this table "activity_plan">
|
//<editor-fold desc="JPA-mappings of other tables referencing to this table "activity_plan">
|
||||||
@OneToMany(mappedBy= "activityPlan",cascade=CascadeType.PERSIST, orphanRemoval = true)
|
@OneToMany(mappedBy = "activityPlan", cascade = CascadeType.PERSIST, orphanRemoval = true)
|
||||||
private Set<Activity> activities = new TreeSet<>(new Activity.ByDateComparator());
|
private Set<Activity> activities = new TreeSet<>(new Activity.ByDateComparator());
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Properties (Getters and Setters)">
|
//<editor-fold desc="Properties (Getters and Setters)">
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
@ -84,6 +85,7 @@ public class ActivityPlan extends DomainObject {
|
|||||||
public void setActivities(Set<Activity> activities) {
|
public void setActivities(Set<Activity> activities) {
|
||||||
this.activities = activities;
|
this.activities = activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Methods Common To All Objects">
|
//<editor-fold desc="Methods Common To All Objects">
|
||||||
@ -92,33 +94,52 @@ public class ActivityPlan extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof ActivityPlan)) return false;
|
if (!(o instanceof ActivityPlan)) return false;
|
||||||
final ActivityPlan other = (ActivityPlan) o;
|
final ActivityPlan other = (ActivityPlan) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& Objects.equals(this.getId(), other.getId())
|
other.canEqual(this) &&
|
||||||
&& Objects.equals(this.getActivities(), other.getActivities())
|
Objects.equals(this.getId(), other.getId()) &&
|
||||||
&& Objects.equals(this.getProject(), other.getProject())
|
Objects.equals(this.getActivities(), other.getActivities()) &&
|
||||||
&& Objects.equals(this.getStartDate(), other.getStartDate());
|
Objects.equals(this.getProject(), other.getProject()) &&
|
||||||
|
Objects.equals(this.getStartDate(), other.getStartDate())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(this.getId(), this.getActivities(), this.getProject(), this.getStartDate());
|
return Objects.hash(
|
||||||
|
this.getId(),
|
||||||
|
this.getActivities(),
|
||||||
|
this.getProject(),
|
||||||
|
this.getStartDate()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ActivityPlan(id=" + this.getId() + ", activities=" + this.getActivities() + ", project=" +
|
return (
|
||||||
this.getProject() + ", startDate=" + this.getStartDate() + ")";
|
"ActivityPlan(id=" +
|
||||||
|
this.getId() +
|
||||||
|
", activities=" +
|
||||||
|
this.getActivities() +
|
||||||
|
", project=" +
|
||||||
|
this.getProject() +
|
||||||
|
", startDate=" +
|
||||||
|
this.getStartDate() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Other methods">
|
//<editor-fold desc="Other methods">
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
return other instanceof ActivityPlan;
|
return other instanceof ActivityPlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Nested types"
|
//<editor-fold desc="Nested types"
|
||||||
private static class Builder implements IProject, IBuild {
|
private static class Builder implements IProject, IBuild {
|
||||||
|
|
||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import se.su.dsv.scipro.checklist.Checklist;
|
import se.su.dsv.scipro.checklist.Checklist;
|
||||||
import se.su.dsv.scipro.checklist.ChecklistTemplate;
|
import se.su.dsv.scipro.checklist.ChecklistTemplate;
|
||||||
import se.su.dsv.scipro.file.ProjectFileUpload;
|
import se.su.dsv.scipro.file.ProjectFileUpload;
|
||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ActivityPlanFacade {
|
public interface ActivityPlanFacade {
|
||||||
|
|
||||||
Activity saveActivity(Activity event);
|
Activity saveActivity(Activity event);
|
||||||
|
|
||||||
ActivityPlan retrieveActivityPlan(Project p);
|
ActivityPlan retrieveActivityPlan(Project p);
|
||||||
@ -22,7 +20,12 @@ public interface ActivityPlanFacade {
|
|||||||
|
|
||||||
void addActivitiesFromTemplate(Project project, ActivityPlanTemplate template, Date startDate);
|
void addActivitiesFromTemplate(Project project, ActivityPlanTemplate template, Date startDate);
|
||||||
|
|
||||||
ActivityPlanTemplate createTemplateFromSchedule(ActivityPlan schedule, User user, String name, String description);
|
ActivityPlanTemplate createTemplateFromSchedule(
|
||||||
|
ActivityPlan schedule,
|
||||||
|
User user,
|
||||||
|
String name,
|
||||||
|
String description
|
||||||
|
);
|
||||||
|
|
||||||
void deleteActivity(Activity event);
|
void deleteActivity(Activity event);
|
||||||
|
|
||||||
@ -30,7 +33,12 @@ public interface ActivityPlanFacade {
|
|||||||
|
|
||||||
//moving from activityservice
|
//moving from activityservice
|
||||||
List<Activity> findEventsByProject(final Project project, Pageable pageable);
|
List<Activity> findEventsByProject(final Project project, Pageable pageable);
|
||||||
List<Activity> findEventsByProject(final Project project, final Date from, final Date to, Pageable pageable);
|
List<Activity> findEventsByProject(
|
||||||
|
final Project project,
|
||||||
|
final Date from,
|
||||||
|
final Date to,
|
||||||
|
Pageable pageable
|
||||||
|
);
|
||||||
long countEventsByProject(final Project project, final Date from, final Date to);
|
long countEventsByProject(final Project project, final Date from, final Date to);
|
||||||
Checklist createChecklist(Project project, ChecklistTemplate template);
|
Checklist createChecklist(Project project, ChecklistTemplate template);
|
||||||
|
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
|
import static com.querydsl.core.types.dsl.Expressions.allOf;
|
||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
|
||||||
import se.su.dsv.scipro.checklist.Checklist;
|
import se.su.dsv.scipro.checklist.Checklist;
|
||||||
import se.su.dsv.scipro.checklist.ChecklistAnswerEnum;
|
import se.su.dsv.scipro.checklist.ChecklistAnswerEnum;
|
||||||
import se.su.dsv.scipro.checklist.ChecklistCategory;
|
import se.su.dsv.scipro.checklist.ChecklistCategory;
|
||||||
@ -21,14 +25,9 @@ import se.su.dsv.scipro.file.ProjectFileService;
|
|||||||
import se.su.dsv.scipro.file.ProjectFileUpload;
|
import se.su.dsv.scipro.file.ProjectFileUpload;
|
||||||
import se.su.dsv.scipro.misc.DaysService;
|
import se.su.dsv.scipro.misc.DaysService;
|
||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import static com.querydsl.core.types.dsl.Expressions.allOf;
|
|
||||||
|
|
||||||
public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ActivityPlanFacadeImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ActivityPlanFacadeImpl.class);
|
||||||
@ -44,17 +43,27 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ActivityService activityService; // yuck
|
ActivityService activityService; // yuck
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ActivityPlanService activityPlanService; //yuck
|
ActivityPlanService activityPlanService; //yuck
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ActivityPlanTemplateService activityPlanTemplateService;
|
ActivityPlanTemplateService activityPlanTemplateService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ChecklistService checklistService;
|
ChecklistService checklistService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ChecklistQuestionRepo checklistQuestionRepo;
|
ChecklistQuestionRepo checklistQuestionRepo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ActivityPlanFacadeImpl(final EventBus eventBus, final ProjectFileService projectFileService, ChecklistTemplateService checklistTemplateService, final DaysService daysService, final FileService fileService) {
|
public ActivityPlanFacadeImpl(
|
||||||
|
final EventBus eventBus,
|
||||||
|
final ProjectFileService projectFileService,
|
||||||
|
ChecklistTemplateService checklistTemplateService,
|
||||||
|
final DaysService daysService,
|
||||||
|
final FileService fileService
|
||||||
|
) {
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.projectFileService = projectFileService;
|
this.projectFileService = projectFileService;
|
||||||
this.checklistTemplateService = checklistTemplateService;
|
this.checklistTemplateService = checklistTemplateService;
|
||||||
@ -71,13 +80,15 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
* @return The newly created event.
|
* @return The newly created event.
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
private Activity createNewActivity(final ActivityPlan ps,
|
private Activity createNewActivity(
|
||||||
String name,
|
final ActivityPlan ps,
|
||||||
String description,
|
String name,
|
||||||
Action action,
|
String description,
|
||||||
final Date date,
|
Action action,
|
||||||
final Checklist checklist,
|
final Date date,
|
||||||
final boolean editable) {
|
final Checklist checklist,
|
||||||
|
final boolean editable
|
||||||
|
) {
|
||||||
Activity pse = new Activity();
|
Activity pse = new Activity();
|
||||||
pse.setActivityPlan(ps);
|
pse.setActivityPlan(ps);
|
||||||
if (date == null) {
|
if (date == null) {
|
||||||
@ -106,16 +117,16 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
if (event.getDescription() == null) {
|
if (event.getDescription() == null) {
|
||||||
event.setDescription("");
|
event.setDescription("");
|
||||||
}
|
}
|
||||||
if (event.getId() == null)//Attempt to create a new one if this is a transient entity
|
if (event.getId() == null) { //Attempt to create a new one if this is a transient entity
|
||||||
{
|
|
||||||
return createNewActivity(
|
return createNewActivity(
|
||||||
event.getActivityPlan(),
|
event.getActivityPlan(),
|
||||||
event.getTitle(),
|
event.getTitle(),
|
||||||
event.getDescription(),
|
event.getDescription(),
|
||||||
event.getAction(),
|
event.getAction(),
|
||||||
event.getDate(),
|
event.getDate(),
|
||||||
event.getChecklist(),
|
event.getChecklist(),
|
||||||
event.isEditable());
|
event.isEditable()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return activityService.save(event);
|
return activityService.save(event);
|
||||||
}
|
}
|
||||||
@ -168,31 +179,44 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void addActivitiesFromTemplate(final Project project, final ActivityPlanTemplate template, final Date startDate) {
|
public void addActivitiesFromTemplate(
|
||||||
|
final Project project,
|
||||||
|
final ActivityPlanTemplate template,
|
||||||
|
final Date startDate
|
||||||
|
) {
|
||||||
addActivitiesFromTemplate(retrieveActivityPlan(project), template, startDate);
|
addActivitiesFromTemplate(retrieveActivityPlan(project), template, startDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addActivitiesFromTemplate(final ActivityPlan schedule,
|
private void addActivitiesFromTemplate(
|
||||||
ActivityPlanTemplate template,
|
final ActivityPlan schedule,
|
||||||
final Date startDate) {
|
ActivityPlanTemplate template,
|
||||||
ActivityPlanTemplate reloadedTemplate = activityPlanTemplateService.findOne(template.getId());//Reload lazily linked entities
|
final Date startDate
|
||||||
|
) {
|
||||||
|
ActivityPlanTemplate reloadedTemplate = activityPlanTemplateService.findOne(
|
||||||
|
template.getId()
|
||||||
|
); //Reload lazily linked entities
|
||||||
int accumulatedOffset = 0;
|
int accumulatedOffset = 0;
|
||||||
for (final ActivityTemplate eventTemplate : reloadedTemplate.getActivityTemplates()) {
|
for (final ActivityTemplate eventTemplate : reloadedTemplate.getActivityTemplates()) {
|
||||||
accumulatedOffset += eventTemplate.getDaysOffset();
|
accumulatedOffset += eventTemplate.getDaysOffset();
|
||||||
final Date dateForEvent = daysService.workDaysAfter(startDate, accumulatedOffset);
|
final Date dateForEvent = daysService.workDaysAfter(startDate, accumulatedOffset);
|
||||||
final String title = eventTemplate.getTitle() != null ? eventTemplate.getTitle() : "no title";
|
final String title = eventTemplate.getTitle() != null
|
||||||
final String desc = eventTemplate.getDescription() != null ? eventTemplate.getDescription() : "";
|
? eventTemplate.getTitle()
|
||||||
|
: "no title";
|
||||||
|
final String desc = eventTemplate.getDescription() != null
|
||||||
|
? eventTemplate.getDescription()
|
||||||
|
: "";
|
||||||
final ChecklistTemplate checklistTemplate = eventTemplate.getChecklistTemplate();
|
final ChecklistTemplate checklistTemplate = eventTemplate.getChecklistTemplate();
|
||||||
final Action action = eventTemplate.getAction();
|
final Action action = eventTemplate.getAction();
|
||||||
if (checklistTemplate != null) {
|
if (checklistTemplate != null) {
|
||||||
createNewActivity(
|
createNewActivity(
|
||||||
schedule,
|
schedule,
|
||||||
title,
|
title,
|
||||||
desc,
|
desc,
|
||||||
action,
|
action,
|
||||||
dateForEvent,
|
dateForEvent,
|
||||||
createChecklist(schedule.getProject(), checklistTemplate),
|
createChecklist(schedule.getProject(), checklistTemplate),
|
||||||
true);
|
true
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
createNewActivity(schedule, title, desc, action, dateForEvent, null, true);
|
createNewActivity(schedule, title, desc, action, dateForEvent, null, true);
|
||||||
}
|
}
|
||||||
@ -205,10 +229,11 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ActivityPlanTemplate createTemplateFromSchedule(
|
public ActivityPlanTemplate createTemplateFromSchedule(
|
||||||
final ActivityPlan schedule,
|
final ActivityPlan schedule,
|
||||||
final User user,
|
final User user,
|
||||||
final String name,
|
final String name,
|
||||||
final String description) {
|
final String description
|
||||||
|
) {
|
||||||
Objects.requireNonNull(schedule, "Schedule may not be null");
|
Objects.requireNonNull(schedule, "Schedule may not be null");
|
||||||
Objects.requireNonNull(user, "User may not be null");
|
Objects.requireNonNull(user, "User may not be null");
|
||||||
|
|
||||||
@ -220,10 +245,15 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
|
|
||||||
Date previousActivityDate = null;
|
Date previousActivityDate = null;
|
||||||
// Fucking Hibernate that replaces the original TreeSet with an unsorted implementation because it can.
|
// Fucking Hibernate that replaces the original TreeSet with an unsorted implementation because it can.
|
||||||
SortedSet<Activity> activities = new TreeSet<>(new Activity.ByDateComparator().thenComparing(Activity::getId));
|
SortedSet<Activity> activities = new TreeSet<>(
|
||||||
|
new Activity.ByDateComparator().thenComparing(Activity::getId)
|
||||||
|
);
|
||||||
activities.addAll(schedule.getActivities());
|
activities.addAll(schedule.getActivities());
|
||||||
for (final Activity activity : activities) {
|
for (final Activity activity : activities) {
|
||||||
final ActivityTemplate activityTemplate = createTemplateFromActivity(previousActivityDate, activity);
|
final ActivityTemplate activityTemplate = createTemplateFromActivity(
|
||||||
|
previousActivityDate,
|
||||||
|
activity
|
||||||
|
);
|
||||||
template.addActivity(activityTemplate);
|
template.addActivity(activityTemplate);
|
||||||
previousActivityDate = activity.getDate();
|
previousActivityDate = activity.getDate();
|
||||||
}
|
}
|
||||||
@ -238,14 +268,17 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
eventTemplate.setDescription(event.getDescription());
|
eventTemplate.setDescription(event.getDescription());
|
||||||
eventTemplate.setAction(event.getAction());
|
eventTemplate.setAction(event.getAction());
|
||||||
if (event.getChecklist() != null) {
|
if (event.getChecklist() != null) {
|
||||||
eventTemplate.setChecklistTemplate(checklistTemplateService.findByName(event.getChecklist().getName()));
|
eventTemplate.setChecklistTemplate(
|
||||||
|
checklistTemplateService.findByName(event.getChecklist().getName())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return eventTemplate;
|
return eventTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int daysBetween(Date previousEventDate, Date currentEventDate) {
|
private int daysBetween(Date previousEventDate, Date currentEventDate) {
|
||||||
return previousEventDate == null ? 0
|
return previousEventDate == null
|
||||||
: daysService.workDaysBetween(previousEventDate, currentEventDate);
|
? 0
|
||||||
|
: daysService.workDaysBetween(previousEventDate, currentEventDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -274,11 +307,23 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Activity> findEventsByProject(Project project, Date from, Date to, Pageable pageable) {
|
public List<Activity> findEventsByProject(
|
||||||
|
Project project,
|
||||||
|
Date from,
|
||||||
|
Date to,
|
||||||
|
Pageable pageable
|
||||||
|
) {
|
||||||
final Date dateFrom = from != null ? from : new Date(0);
|
final Date dateFrom = from != null ? from : new Date(0);
|
||||||
final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE;
|
final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE;
|
||||||
QActivity event = QActivity.activity;
|
QActivity event = QActivity.activity;
|
||||||
return activityService.findAll(allOf(event.activityPlan.project.eq(project), event.date.after(dateFrom), event.date.before(dateTo)), pageable);
|
return activityService.findAll(
|
||||||
|
allOf(
|
||||||
|
event.activityPlan.project.eq(project),
|
||||||
|
event.date.after(dateFrom),
|
||||||
|
event.date.before(dateTo)
|
||||||
|
),
|
||||||
|
pageable
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -286,7 +331,13 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
final Date dateFrom = from != null ? from : new Date(0);
|
final Date dateFrom = from != null ? from : new Date(0);
|
||||||
final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE;
|
final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE;
|
||||||
QActivity event = QActivity.activity;
|
QActivity event = QActivity.activity;
|
||||||
return activityService.count(allOf(event.activityPlan.project.eq(project), event.date.after(dateFrom), event.date.before(dateTo)));
|
return activityService.count(
|
||||||
|
allOf(
|
||||||
|
event.activityPlan.project.eq(project),
|
||||||
|
event.date.after(dateFrom),
|
||||||
|
event.date.before(dateTo)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteUpload(Activity activity) {
|
private void deleteUpload(Activity activity) {
|
||||||
@ -303,10 +354,17 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
@Override
|
@Override
|
||||||
public Checklist createChecklist(Project project, ChecklistTemplate template) {
|
public Checklist createChecklist(Project project, ChecklistTemplate template) {
|
||||||
List<ChecklistCategory> categories = new ArrayList<>(template.getCategories());
|
List<ChecklistCategory> categories = new ArrayList<>(template.getCategories());
|
||||||
Checklist checklist = Checklist.builder().name(template.getName()).project(project).description(template.getDescription()).build();
|
Checklist checklist = Checklist.builder()
|
||||||
|
.name(template.getName())
|
||||||
|
.project(project)
|
||||||
|
.description(template.getDescription())
|
||||||
|
.build();
|
||||||
checklist.setCategories(categories);
|
checklist.setCategories(categories);
|
||||||
for (String question : template.getQuestions()) {
|
for (String question : template.getQuestions()) {
|
||||||
ChecklistQuestion clQuestion = new ChecklistQuestion(question, checklist.getNumberOfQuestions());
|
ChecklistQuestion clQuestion = new ChecklistQuestion(
|
||||||
|
question,
|
||||||
|
checklist.getNumberOfQuestions()
|
||||||
|
);
|
||||||
clQuestion = checklistQuestionRepo.save(clQuestion);
|
clQuestion = checklistQuestionRepo.save(clQuestion);
|
||||||
checklist.addQuestion(clQuestion);
|
checklist.addQuestion(clQuestion);
|
||||||
}
|
}
|
||||||
@ -350,5 +408,4 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,4 @@ package se.su.dsv.scipro.activityplan;
|
|||||||
|
|
||||||
import se.su.dsv.scipro.system.GenericService;
|
import se.su.dsv.scipro.system.GenericService;
|
||||||
|
|
||||||
public interface ActivityPlanService extends GenericService<ActivityPlan, Long> {
|
public interface ActivityPlanService extends GenericService<ActivityPlan, Long> {}
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
|
||||||
public class ActivityPlanServiceImpl extends AbstractServiceImpl<ActivityPlan,Long> implements ActivityPlanService {
|
public class ActivityPlanServiceImpl
|
||||||
@Inject
|
extends AbstractServiceImpl<ActivityPlan, Long>
|
||||||
public ActivityPlanServiceImpl(Provider<EntityManager> em) {
|
implements ActivityPlanService {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public ActivityPlanServiceImpl(Provider<EntityManager> em) {
|
||||||
super(em, ActivityPlan.class, QActivityPlan.activityPlan);
|
super(em, ActivityPlan.class, QActivityPlan.activityPlan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
import jakarta.persistence.Basic;
|
||||||
import jakarta.persistence.Cacheable;
|
import jakarta.persistence.Cacheable;
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
@ -19,8 +13,12 @@ import jakarta.persistence.Lob;
|
|||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.OrderColumn;
|
import jakarta.persistence.OrderColumn;
|
||||||
|
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@ -29,134 +27,158 @@ import se.su.dsv.scipro.system.User;
|
|||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
public class ActivityPlanTemplate extends DomainObject {
|
public class ActivityPlanTemplate extends DomainObject {
|
||||||
|
|
||||||
//<editor-fold desc="Basic JPA-mappings">
|
//<editor-fold desc="Basic JPA-mappings">
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "is_sys_admin_template", nullable=false)
|
@Column(name = "is_sys_admin_template", nullable = false)
|
||||||
private boolean isSysAdminTemplate = false;
|
private boolean isSysAdminTemplate = false;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "title", nullable = false)
|
@Column(name = "title", nullable = false)
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "description")
|
@Column(name = "description")
|
||||||
@Lob
|
@Lob
|
||||||
private String description;
|
private String description;
|
||||||
//</editor-fold>
|
|
||||||
|
|
||||||
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan_template) referencing other tables.">
|
//</editor-fold>
|
||||||
@ManyToOne(optional = false)
|
|
||||||
@JoinColumn(name = "creator_user_id", referencedColumnName = "id")
|
|
||||||
private User creator;
|
|
||||||
//</editor-fold>
|
|
||||||
|
|
||||||
//<editor-fold desc="JPA-mappings of other tables referencing to this table 'activity_plan_template'">
|
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan_template) referencing other tables.">
|
||||||
@OneToMany(mappedBy="activityPlanTemplate", orphanRemoval=true, cascade=CascadeType.ALL)
|
@ManyToOne(optional = false)
|
||||||
@OrderColumn(name = "number_in_order")
|
@JoinColumn(name = "creator_user_id", referencedColumnName = "id")
|
||||||
private List<ActivityTemplate> activityTemplates = new ArrayList<>();
|
private User creator;
|
||||||
//</editor-fold>
|
|
||||||
|
|
||||||
//<editor-fold desc="Properties (Getters and Setters)">
|
//</editor-fold>
|
||||||
@Override
|
|
||||||
public Long getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
//<editor-fold desc="JPA-mappings of other tables referencing to this table 'activity_plan_template'">
|
||||||
this.id = id;
|
@OneToMany(mappedBy = "activityPlanTemplate", orphanRemoval = true, cascade = CascadeType.ALL)
|
||||||
}
|
@OrderColumn(name = "number_in_order")
|
||||||
|
private List<ActivityTemplate> activityTemplates = new ArrayList<>();
|
||||||
|
|
||||||
public boolean isSysAdminTemplate() {
|
//</editor-fold>
|
||||||
return this.isSysAdminTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSysAdminTemplate(boolean isSysAdminTemplate) {
|
//<editor-fold desc="Properties (Getters and Setters)">
|
||||||
this.isSysAdminTemplate = isSysAdminTemplate;
|
@Override
|
||||||
}
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public void setId(Long id) {
|
||||||
return this.title;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public boolean isSysAdminTemplate() {
|
||||||
this.title = title;
|
return this.isSysAdminTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public void setSysAdminTemplate(boolean isSysAdminTemplate) {
|
||||||
return this.description;
|
this.isSysAdminTemplate = isSysAdminTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public String getTitle() {
|
||||||
this.description = description;
|
return this.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getCreator() {
|
public void setTitle(String title) {
|
||||||
return this.creator;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreator(User creator) {
|
public String getDescription() {
|
||||||
this.creator = creator;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ActivityTemplate> getActivityTemplates(){
|
public void setDescription(String description) {
|
||||||
return Collections.unmodifiableList(activityTemplates);
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivityTemplates(List<ActivityTemplate> activityTemplates){
|
public User getCreator() {
|
||||||
this.activityTemplates = new ArrayList<>(activityTemplates);
|
return this.creator;
|
||||||
}
|
}
|
||||||
//</editor-fold>
|
|
||||||
|
|
||||||
//<editor-fold desc="Methods Common To All Objects">
|
public void setCreator(User creator) {
|
||||||
@Override
|
this.creator = creator;
|
||||||
public boolean equals(final Object o) {
|
}
|
||||||
if (o == this) return true;
|
|
||||||
if (!(o instanceof ActivityPlanTemplate)) return false;
|
|
||||||
final ActivityPlanTemplate other = (ActivityPlanTemplate) o;
|
|
||||||
return other.canEqual(this)
|
|
||||||
&& super.equals(o)
|
|
||||||
&& Objects.equals(this.getId(), other.getId())
|
|
||||||
&& Objects.equals(this.getActivityTemplates(), other.getActivityTemplates())
|
|
||||||
&& Objects.equals(this.getCreator(), other.getCreator())
|
|
||||||
&& Objects.equals(this.getTitle(), other.getTitle())
|
|
||||||
&& Objects.equals(this.getDescription(), other.getDescription())
|
|
||||||
&& this.isSysAdminTemplate() == other.isSysAdminTemplate();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
public List<ActivityTemplate> getActivityTemplates() {
|
||||||
return other instanceof ActivityPlanTemplate;
|
return Collections.unmodifiableList(activityTemplates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setActivityTemplates(List<ActivityTemplate> activityTemplates) {
|
||||||
public int hashCode() {
|
this.activityTemplates = new ArrayList<>(activityTemplates);
|
||||||
return Objects.hash(this.getId(), this.getActivityTemplates(), this.getCreator(), this.getTitle(), this.getDescription(), this.isSysAdminTemplate());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
//</editor-fold>
|
||||||
public String toString() {
|
|
||||||
return "ActivityPlanTemplate(id=" + this.getId() + ", creator=" + this.getCreator() +
|
|
||||||
", title=" + this.getTitle() + ", description=" + this.getDescription() +
|
|
||||||
", isSysAdminTemplate=" + this.isSysAdminTemplate() + ")";
|
|
||||||
}
|
|
||||||
//</editor-fold>
|
|
||||||
|
|
||||||
//<editor-fold desc="Other methods">
|
//<editor-fold desc="Methods Common To All Objects">
|
||||||
public void addActivity(ActivityTemplate activity){
|
@Override
|
||||||
activity.setActivityPlanTemplate(this);
|
public boolean equals(final Object o) {
|
||||||
activity.setNumberInOrder(activityTemplates.size());
|
if (o == this) return true;
|
||||||
activityTemplates.add(activity);
|
if (!(o instanceof ActivityPlanTemplate)) return false;
|
||||||
}
|
final ActivityPlanTemplate other = (ActivityPlanTemplate) o;
|
||||||
|
return (
|
||||||
|
other.canEqual(this) &&
|
||||||
|
super.equals(o) &&
|
||||||
|
Objects.equals(this.getId(), other.getId()) &&
|
||||||
|
Objects.equals(this.getActivityTemplates(), other.getActivityTemplates()) &&
|
||||||
|
Objects.equals(this.getCreator(), other.getCreator()) &&
|
||||||
|
Objects.equals(this.getTitle(), other.getTitle()) &&
|
||||||
|
Objects.equals(this.getDescription(), other.getDescription()) &&
|
||||||
|
this.isSysAdminTemplate() == other.isSysAdminTemplate()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public void clearActivities(){
|
protected boolean canEqual(final Object other) {
|
||||||
activityTemplates.clear();
|
return other instanceof ActivityPlanTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addActivities(final Collection<ActivityTemplate> activities){
|
@Override
|
||||||
activityTemplates.addAll(activities);
|
public int hashCode() {
|
||||||
}
|
return Objects.hash(
|
||||||
//</editor-fold>
|
this.getId(),
|
||||||
|
this.getActivityTemplates(),
|
||||||
|
this.getCreator(),
|
||||||
|
this.getTitle(),
|
||||||
|
this.getDescription(),
|
||||||
|
this.isSysAdminTemplate()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return (
|
||||||
|
"ActivityPlanTemplate(id=" +
|
||||||
|
this.getId() +
|
||||||
|
", creator=" +
|
||||||
|
this.getCreator() +
|
||||||
|
", title=" +
|
||||||
|
this.getTitle() +
|
||||||
|
", description=" +
|
||||||
|
this.getDescription() +
|
||||||
|
", isSysAdminTemplate=" +
|
||||||
|
this.isSysAdminTemplate() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
//<editor-fold desc="Other methods">
|
||||||
|
public void addActivity(ActivityTemplate activity) {
|
||||||
|
activity.setActivityPlanTemplate(this);
|
||||||
|
activity.setNumberInOrder(activityTemplates.size());
|
||||||
|
activityTemplates.add(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearActivities() {
|
||||||
|
activityTemplates.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addActivities(final Collection<ActivityTemplate> activities) {
|
||||||
|
activityTemplates.addAll(activities);
|
||||||
|
}
|
||||||
|
//</editor-fold>
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.FilteredService;
|
|
||||||
import se.su.dsv.scipro.system.GenericService;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import se.su.dsv.scipro.system.FilteredService;
|
||||||
|
import se.su.dsv.scipro.system.GenericService;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
public interface ActivityPlanTemplateService extends GenericService<ActivityPlanTemplate, Long>, FilteredService<ActivityPlanTemplate, Long, ActivityPlanTemplateService.Filter> {
|
public interface ActivityPlanTemplateService
|
||||||
|
extends
|
||||||
|
GenericService<ActivityPlanTemplate, Long>,
|
||||||
|
FilteredService<ActivityPlanTemplate, Long, ActivityPlanTemplateService.Filter> {
|
||||||
List<ActivityPlanTemplate> findAll(Filter filter);
|
List<ActivityPlanTemplate> findAll(Filter filter);
|
||||||
|
|
||||||
class Filter implements Serializable {
|
class Filter implements Serializable {
|
||||||
|
|
||||||
private String filterString;
|
private String filterString;
|
||||||
private User creator;
|
private User creator;
|
||||||
|
|
||||||
@ -37,9 +39,11 @@ public interface ActivityPlanTemplateService extends GenericService<ActivityPlan
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof Filter)) return false;
|
if (!(o instanceof Filter)) return false;
|
||||||
final Filter other = (Filter) o;
|
final Filter other = (Filter) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& Objects.equals(this.getFilterString(), other.getFilterString())
|
other.canEqual(this) &&
|
||||||
&& Objects.equals(this.getCreator(), other.getCreator());
|
Objects.equals(this.getFilterString(), other.getFilterString()) &&
|
||||||
|
Objects.equals(this.getCreator(), other.getCreator())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
@ -53,7 +57,13 @@ public interface ActivityPlanTemplateService extends GenericService<ActivityPlan
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ActivityPlanTemplateService.Filter(filterString=" + this.getFilterString() + ", creator=" + this.getCreator() + ")";
|
return (
|
||||||
|
"ActivityPlanTemplateService.Filter(filterString=" +
|
||||||
|
this.getFilterString() +
|
||||||
|
", creator=" +
|
||||||
|
this.getCreator() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,18 @@ package se.su.dsv.scipro.activityplan;
|
|||||||
|
|
||||||
import com.querydsl.core.BooleanBuilder;
|
import com.querydsl.core.BooleanBuilder;
|
||||||
import com.querydsl.core.types.Predicate;
|
import com.querydsl.core.types.Predicate;
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
|
public class ActivityPlanTemplateServiceImpl
|
||||||
|
extends AbstractServiceImpl<ActivityPlanTemplate, Long>
|
||||||
|
implements ActivityPlanTemplateService {
|
||||||
|
|
||||||
public class ActivityPlanTemplateServiceImpl extends AbstractServiceImpl<ActivityPlanTemplate, Long> implements ActivityPlanTemplateService {
|
|
||||||
@Inject
|
@Inject
|
||||||
public ActivityPlanTemplateServiceImpl(Provider<EntityManager> em) {
|
public ActivityPlanTemplateServiceImpl(Provider<EntityManager> em) {
|
||||||
super(em, ActivityPlanTemplate.class, QActivityPlanTemplate.activityPlanTemplate);
|
super(em, ActivityPlanTemplate.class, QActivityPlanTemplate.activityPlanTemplate);
|
||||||
@ -31,23 +32,34 @@ public class ActivityPlanTemplateServiceImpl extends AbstractServiceImpl<Activit
|
|||||||
protected static Predicate toPredicate(ActivityPlanTemplateService.Filter filter) {
|
protected static Predicate toPredicate(ActivityPlanTemplateService.Filter filter) {
|
||||||
BooleanBuilder predicate = new BooleanBuilder();
|
BooleanBuilder predicate = new BooleanBuilder();
|
||||||
|
|
||||||
if (filter.getFilterString()!=null){
|
if (filter.getFilterString() != null) {
|
||||||
predicate.and(filterString(filter.getFilterString()));
|
predicate.and(filterString(filter.getFilterString()));
|
||||||
}
|
}
|
||||||
if (filter.getCreator()!=null){
|
if (filter.getCreator() != null) {
|
||||||
predicate.and(creator(filter.getCreator()));
|
predicate.and(creator(filter.getCreator()));
|
||||||
}
|
}
|
||||||
return predicate;
|
return predicate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate creator(User creator) {
|
private static Predicate creator(User creator) {
|
||||||
return QActivityPlanTemplate.activityPlanTemplate.isSysAdminTemplate.isTrue().or(QActivityPlanTemplate.activityPlanTemplate.creator.eq(creator));
|
return QActivityPlanTemplate.activityPlanTemplate.isSysAdminTemplate
|
||||||
|
.isTrue()
|
||||||
|
.or(QActivityPlanTemplate.activityPlanTemplate.creator.eq(creator));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate filterString(String filterString) {
|
private static Predicate filterString(String filterString) {
|
||||||
return QActivityPlanTemplate.activityPlanTemplate.title.containsIgnoreCase(filterString)
|
return QActivityPlanTemplate.activityPlanTemplate.title
|
||||||
.or(QActivityPlanTemplate.activityPlanTemplate.creator.firstName.containsIgnoreCase(filterString))
|
.containsIgnoreCase(filterString)
|
||||||
.or(QActivityPlanTemplate.activityPlanTemplate.creator.lastName.containsIgnoreCase(filterString));
|
.or(
|
||||||
|
QActivityPlanTemplate.activityPlanTemplate.creator.firstName.containsIgnoreCase(
|
||||||
|
filterString
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.or(
|
||||||
|
QActivityPlanTemplate.activityPlanTemplate.creator.lastName.containsIgnoreCase(
|
||||||
|
filterString
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,6 +2,4 @@ package se.su.dsv.scipro.activityplan;
|
|||||||
|
|
||||||
import se.su.dsv.scipro.system.GenericService;
|
import se.su.dsv.scipro.system.GenericService;
|
||||||
|
|
||||||
public interface ActivityService extends GenericService<Activity, Long> {
|
public interface ActivityService extends GenericService<Activity, Long> {}
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
|
||||||
public class ActivityServiceImpl extends AbstractServiceImpl<Activity, Long> implements ActivityService {
|
public class ActivityServiceImpl
|
||||||
|
extends AbstractServiceImpl<Activity, Long>
|
||||||
|
implements ActivityService {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ActivityServiceImpl(Provider<EntityManager> em) {
|
public ActivityServiceImpl(Provider<EntityManager> em) {
|
||||||
super(em, Activity.class, QActivity.activity);
|
super(em, Activity.class, QActivity.activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
import jakarta.persistence.Basic;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
@ -14,7 +12,7 @@ import jakarta.persistence.JoinColumn;
|
|||||||
import jakarta.persistence.Lob;
|
import jakarta.persistence.Lob;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import java.util.Objects;
|
||||||
import se.su.dsv.scipro.checklist.ChecklistTemplate;
|
import se.su.dsv.scipro.checklist.ChecklistTemplate;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
|
||||||
@ -48,6 +46,7 @@ public class ActivityTemplate extends DomainObject {
|
|||||||
@Basic
|
@Basic
|
||||||
@Column(name = "number_in_order", nullable = false)
|
@Column(name = "number_in_order", nullable = false)
|
||||||
private int numberInOrder = Integer.MAX_VALUE;
|
private int numberInOrder = Integer.MAX_VALUE;
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_template) referencing other tables.">
|
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_template) referencing other tables.">
|
||||||
@ -58,15 +57,16 @@ public class ActivityTemplate extends DomainObject {
|
|||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true)
|
||||||
@JoinColumn(name = "checklist_template_id", referencedColumnName = "id")
|
@JoinColumn(name = "checklist_template_id", referencedColumnName = "id")
|
||||||
private ChecklistTemplate checklistTemplate;
|
private ChecklistTemplate checklistTemplate;
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Constructors">
|
//<editor-fold desc="Constructors">
|
||||||
public ActivityTemplate() {
|
public ActivityTemplate() {}
|
||||||
}
|
|
||||||
|
|
||||||
public ActivityTemplate(int daysOffset) {
|
public ActivityTemplate(int daysOffset) {
|
||||||
this.daysOffset = daysOffset;
|
this.daysOffset = daysOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Properties (Getters and Setters">
|
//<editor-fold desc="Properties (Getters and Setters">
|
||||||
@ -134,6 +134,7 @@ public class ActivityTemplate extends DomainObject {
|
|||||||
public void setChecklistTemplate(ChecklistTemplate checklistTemplate) {
|
public void setChecklistTemplate(ChecklistTemplate checklistTemplate) {
|
||||||
this.checklistTemplate = checklistTemplate;
|
this.checklistTemplate = checklistTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Methods Common To All Objects">
|
//<editor-fold desc="Methods Common To All Objects">
|
||||||
@ -142,8 +143,7 @@ public class ActivityTemplate extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof ActivityTemplate)) return false;
|
if (!(o instanceof ActivityTemplate)) return false;
|
||||||
final ActivityTemplate other = (ActivityTemplate) o;
|
final ActivityTemplate other = (ActivityTemplate) o;
|
||||||
return other.canEqual(this)
|
return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
|
||||||
&& Objects.equals(this.getId(), other.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -153,12 +153,27 @@ public class ActivityTemplate extends DomainObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ActivityTemplate(id=" + this.getId() + ", title=" + this.getTitle() +
|
return (
|
||||||
", description=" + this.getDescription() + ", activityPlanTemplate=" +
|
"ActivityTemplate(id=" +
|
||||||
this.getActivityPlanTemplate() + ", daysOffset=" + this.getDaysOffset() + ", action=" +
|
this.getId() +
|
||||||
this.getAction() + ", numberInOrder=" + this.getNumberInOrder() + ", checklistTemplate=" +
|
", title=" +
|
||||||
this.getChecklistTemplate() + ")";
|
this.getTitle() +
|
||||||
|
", description=" +
|
||||||
|
this.getDescription() +
|
||||||
|
", activityPlanTemplate=" +
|
||||||
|
this.getActivityPlanTemplate() +
|
||||||
|
", daysOffset=" +
|
||||||
|
this.getDaysOffset() +
|
||||||
|
", action=" +
|
||||||
|
this.getAction() +
|
||||||
|
", numberInOrder=" +
|
||||||
|
this.getNumberInOrder() +
|
||||||
|
", checklistTemplate=" +
|
||||||
|
this.getChecklistTemplate() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Other methods">
|
//<editor-fold desc="Other methods">
|
||||||
|
@ -18,16 +18,15 @@ import jakarta.persistence.ManyToOne;
|
|||||||
import jakarta.persistence.MapKeyJoinColumn;
|
import jakarta.persistence.MapKeyJoinColumn;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "checklist")
|
@Table(name = "checklist")
|
||||||
@ -54,26 +53,38 @@ public class Checklist extends DomainObject {
|
|||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
@JoinTable(name = "checklist_checklist_question",
|
@JoinTable(
|
||||||
joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"),
|
name = "checklist_checklist_question",
|
||||||
inverseJoinColumns = @JoinColumn(name = "checklist_question_id", referencedColumnName = "id"))
|
joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"),
|
||||||
|
inverseJoinColumns = @JoinColumn(
|
||||||
|
name = "checklist_question_id",
|
||||||
|
referencedColumnName = "id"
|
||||||
|
)
|
||||||
|
)
|
||||||
private List<ChecklistQuestion> questions = new ArrayList<>();
|
private List<ChecklistQuestion> questions = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "checklist_checklist_category",
|
@JoinTable(
|
||||||
joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"),
|
name = "checklist_checklist_category",
|
||||||
inverseJoinColumns = @JoinColumn(name = "checklist_category_id", referencedColumnName = "id"))
|
joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"),
|
||||||
|
inverseJoinColumns = @JoinColumn(
|
||||||
|
name = "checklist_category_id",
|
||||||
|
referencedColumnName = "id"
|
||||||
|
)
|
||||||
|
)
|
||||||
private List<se.su.dsv.scipro.checklist.ChecklistCategory> categories = new ArrayList<>();
|
private List<se.su.dsv.scipro.checklist.ChecklistCategory> categories = new ArrayList<>();
|
||||||
|
|
||||||
@ElementCollection(fetch = FetchType.EAGER)
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@CollectionTable(name = "checklist_user_last_open_date", joinColumns = @JoinColumn(name = "checklist_id"))
|
@CollectionTable(
|
||||||
|
name = "checklist_user_last_open_date",
|
||||||
|
joinColumns = @JoinColumn(name = "checklist_id")
|
||||||
|
)
|
||||||
@Column(name = "last_open_date")
|
@Column(name = "last_open_date")
|
||||||
@SuppressWarnings("JpaDataSourceORMInspection") // false warning from IntelliJ for the @MapKeyJoinColumn
|
@SuppressWarnings("JpaDataSourceORMInspection") // false warning from IntelliJ for the @MapKeyJoinColumn
|
||||||
@MapKeyJoinColumn(name = "user_id")
|
@MapKeyJoinColumn(name = "user_id")
|
||||||
private Map<User, Date> userLastOpenDate = new HashMap<>();
|
private Map<User, Date> userLastOpenDate = new HashMap<>();
|
||||||
|
|
||||||
protected Checklist() {
|
protected Checklist() {}
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumberOfQuestions() {
|
public int getNumberOfQuestions() {
|
||||||
return questions.size();
|
return questions.size();
|
||||||
@ -148,7 +159,23 @@ public class Checklist extends DomainObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Checklist(id=" + this.getId() + ", name=" + this.getName() + ", description=" + this.getDescription() + ", project=" + this.getProject() + ", questions=" + this.getQuestions() + ", categories=" + this.getCategories() + ", userLastOpenDate=" + this.getUserLastOpenDate() + ")";
|
return (
|
||||||
|
"Checklist(id=" +
|
||||||
|
this.getId() +
|
||||||
|
", name=" +
|
||||||
|
this.getName() +
|
||||||
|
", description=" +
|
||||||
|
this.getDescription() +
|
||||||
|
", project=" +
|
||||||
|
this.getProject() +
|
||||||
|
", questions=" +
|
||||||
|
this.getQuestions() +
|
||||||
|
", categories=" +
|
||||||
|
this.getCategories() +
|
||||||
|
", userLastOpenDate=" +
|
||||||
|
this.getUserLastOpenDate() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -156,8 +183,7 @@ public class Checklist extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof Checklist)) return false;
|
if (!(o instanceof Checklist)) return false;
|
||||||
final Checklist other = (Checklist) o;
|
final Checklist other = (Checklist) o;
|
||||||
return other.canEqual(this)
|
return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
|
||||||
&& Objects.equals(this.getId(), other.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
@ -170,6 +196,7 @@ public class Checklist extends DomainObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Builder implements IName, IProject, IBuild {
|
private static class Builder implements IName, IProject, IBuild {
|
||||||
|
|
||||||
private final Checklist instance = new Checklist();
|
private final Checklist instance = new Checklist();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -204,12 +231,9 @@ public class Checklist extends DomainObject {
|
|||||||
IBuild project(Project project);
|
IBuild project(Project project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface IBuild {
|
public interface IBuild {
|
||||||
|
|
||||||
IBuild description(String description);
|
IBuild description(String description);
|
||||||
|
|
||||||
Checklist build();
|
Checklist build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
import jakarta.persistence.Basic;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
@ -14,13 +12,14 @@ import jakarta.persistence.JoinColumn;
|
|||||||
import jakarta.persistence.Lob;
|
import jakarta.persistence.Lob;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import java.util.Objects;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "checklist_answer")
|
@Table(name = "checklist_answer")
|
||||||
public class ChecklistAnswer extends DomainObject {
|
public class ChecklistAnswer extends DomainObject {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// Basic JPA-mappings
|
// Basic JPA-mappings
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
@ -49,8 +48,7 @@ public class ChecklistAnswer extends DomainObject {
|
|||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// Constructors
|
// Constructors
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
protected ChecklistAnswer() {
|
protected ChecklistAnswer() {}
|
||||||
}
|
|
||||||
|
|
||||||
public ChecklistAnswer(User user) {
|
public ChecklistAnswer(User user) {
|
||||||
this(user, null);
|
this(user, null);
|
||||||
@ -105,8 +103,7 @@ public class ChecklistAnswer extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof ChecklistAnswer)) return false;
|
if (!(o instanceof ChecklistAnswer)) return false;
|
||||||
final ChecklistAnswer other = (ChecklistAnswer) o;
|
final ChecklistAnswer other = (ChecklistAnswer) o;
|
||||||
return other.canEqual(this)
|
return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
|
||||||
&& Objects.equals(this.getId(), other.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,8 +113,17 @@ public class ChecklistAnswer extends DomainObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ChecklistAnswer(id=" + this.getId() + ", answer=" + this.getAnswer() + ", user=" + this.getUser() +
|
return (
|
||||||
", comment=" + this.getComment() + ")";
|
"ChecklistAnswer(id=" +
|
||||||
|
this.getId() +
|
||||||
|
", answer=" +
|
||||||
|
this.getAnswer() +
|
||||||
|
", user=" +
|
||||||
|
this.getUser() +
|
||||||
|
", comment=" +
|
||||||
|
this.getComment() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
@ -126,4 +132,4 @@ public class ChecklistAnswer extends DomainObject {
|
|||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
return other instanceof ChecklistAnswer;
|
return other instanceof ChecklistAnswer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
public enum ChecklistAnswerEnum {
|
public enum ChecklistAnswerEnum {
|
||||||
RED,
|
RED,
|
||||||
GREEN,
|
GREEN,
|
||||||
YELLOW,
|
YELLOW,
|
||||||
NOT_APPLICABLE,
|
NOT_APPLICABLE,
|
||||||
NO_ANSWER
|
NO_ANSWER,
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,4 @@ package se.su.dsv.scipro.checklist;
|
|||||||
|
|
||||||
import se.su.dsv.scipro.system.GenericService;
|
import se.su.dsv.scipro.system.GenericService;
|
||||||
|
|
||||||
public interface ChecklistAnswerService extends GenericService<ChecklistAnswer, Long> {
|
public interface ChecklistAnswerService extends GenericService<ChecklistAnswer, Long> {}
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
|
||||||
public class ChecklistAnswerServiceImpl extends AbstractServiceImpl<ChecklistAnswer, Long> implements ChecklistAnswerService {
|
public class ChecklistAnswerServiceImpl
|
||||||
|
extends AbstractServiceImpl<ChecklistAnswer, Long>
|
||||||
|
implements ChecklistAnswerService {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ChecklistAnswerServiceImpl(Provider<EntityManager> em) {
|
public ChecklistAnswerServiceImpl(Provider<EntityManager> em) {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import jakarta.persistence.Cacheable;
|
import jakarta.persistence.Cacheable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
@ -9,64 +7,69 @@ import jakarta.persistence.GeneratedValue;
|
|||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import java.util.Objects;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="checklist_category")
|
@Table(name = "checklist_category")
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
public class ChecklistCategory extends DomainObject {
|
public class ChecklistCategory extends DomainObject {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(name = "category_name", unique = true)
|
|
||||||
private String categoryName;
|
|
||||||
|
|
||||||
protected ChecklistCategory() {
|
@Column(name = "category_name", unique = true)
|
||||||
}
|
private String categoryName;
|
||||||
|
|
||||||
public ChecklistCategory(final String name){
|
|
||||||
categoryName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
protected ChecklistCategory() {}
|
||||||
public Long getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCategoryName() {
|
public ChecklistCategory(final String name) {
|
||||||
return this.categoryName;
|
categoryName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
@Override
|
||||||
this.id = id;
|
public Long getId() {
|
||||||
}
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCategoryName(String categoryName) {
|
public String getCategoryName() {
|
||||||
this.categoryName = categoryName;
|
return this.categoryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setId(Long id) {
|
||||||
public String toString() {
|
this.id = id;
|
||||||
return "ChecklistCategory(id=" + this.getId() + ", categoryName=" + this.getCategoryName() + ")";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void setCategoryName(String categoryName) {
|
||||||
public boolean equals(final Object o) {
|
this.categoryName = categoryName;
|
||||||
if (o == this) return true;
|
}
|
||||||
if (!(o instanceof ChecklistCategory)) return false;
|
|
||||||
final ChecklistCategory other = (ChecklistCategory) o;
|
|
||||||
return other.canEqual(this)
|
|
||||||
&& Objects.equals(this.getId(), other.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
@Override
|
||||||
return other instanceof ChecklistCategory;
|
public String toString() {
|
||||||
}
|
return (
|
||||||
|
"ChecklistCategory(id=" +
|
||||||
|
this.getId() +
|
||||||
|
", categoryName=" +
|
||||||
|
this.getCategoryName() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(final Object o) {
|
||||||
return Objects.hashCode(this.getId());
|
if (o == this) return true;
|
||||||
}
|
if (!(o instanceof ChecklistCategory)) return false;
|
||||||
|
final ChecklistCategory other = (ChecklistCategory) o;
|
||||||
|
return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof ChecklistCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(this.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import jakarta.transaction.Transactional;
|
|||||||
import se.su.dsv.scipro.system.JpaRepository;
|
import se.su.dsv.scipro.system.JpaRepository;
|
||||||
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public interface ChecklistCategoryRepo extends JpaRepository<ChecklistCategory, Long>, QueryDslPredicateExecutor<ChecklistCategory> {
|
public interface ChecklistCategoryRepo
|
||||||
|
extends JpaRepository<ChecklistCategory, Long>, QueryDslPredicateExecutor<ChecklistCategory> {}
|
||||||
}
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.GenericRepo;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import se.su.dsv.scipro.system.GenericRepo;
|
||||||
|
|
||||||
|
public class ChecklistCategoryRepoImpl
|
||||||
|
extends GenericRepo<ChecklistCategory, Long>
|
||||||
|
implements ChecklistCategoryRepo {
|
||||||
|
|
||||||
public class ChecklistCategoryRepoImpl extends GenericRepo<ChecklistCategory, Long> implements ChecklistCategoryRepo {
|
|
||||||
@Inject
|
@Inject
|
||||||
public ChecklistCategoryRepoImpl(Provider<EntityManager> em) {
|
public ChecklistCategoryRepoImpl(Provider<EntityManager> em) {
|
||||||
super(em, ChecklistCategory.class, QChecklistCategory.checklistCategory);
|
super(em, ChecklistCategory.class, QChecklistCategory.checklistCategory);
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
import jakarta.persistence.Basic;
|
||||||
import jakarta.persistence.Cacheable;
|
import jakarta.persistence.Cacheable;
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
@ -17,7 +13,9 @@ import jakarta.persistence.JoinTable;
|
|||||||
import jakarta.persistence.Lob;
|
import jakarta.persistence.Lob;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@ -25,6 +23,7 @@ import se.su.dsv.scipro.system.User;
|
|||||||
@Table(name = "checklist_question")
|
@Table(name = "checklist_question")
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
public class ChecklistQuestion extends DomainObject {
|
public class ChecklistQuestion extends DomainObject {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
@ -39,13 +38,13 @@ public class ChecklistQuestion extends DomainObject {
|
|||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "checklist_question_checklist_answer",
|
name = "checklist_question_checklist_answer",
|
||||||
joinColumns = @JoinColumn(name = "checklist_question_id", referencedColumnName = "id"),
|
joinColumns = @JoinColumn(name = "checklist_question_id", referencedColumnName = "id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "checklist_answer_id", referencedColumnName = "id"))
|
inverseJoinColumns = @JoinColumn(name = "checklist_answer_id", referencedColumnName = "id")
|
||||||
|
)
|
||||||
private List<ChecklistAnswer> answers = new ArrayList<>();
|
private List<ChecklistAnswer> answers = new ArrayList<>();
|
||||||
|
|
||||||
protected ChecklistQuestion() {
|
protected ChecklistQuestion() {}
|
||||||
}
|
|
||||||
|
|
||||||
public ChecklistQuestion(String question, int questionNumber) {
|
public ChecklistQuestion(String question, int questionNumber) {
|
||||||
this.question = question;
|
this.question = question;
|
||||||
@ -104,7 +103,17 @@ public class ChecklistQuestion extends DomainObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ChecklistQuestion(id=" + this.getId() + ", question=" + this.getQuestion() + ", questionNumber=" + this.getQuestionNumber() + ", answers=" + this.getAnswers() + ")";
|
return (
|
||||||
|
"ChecklistQuestion(id=" +
|
||||||
|
this.getId() +
|
||||||
|
", question=" +
|
||||||
|
this.getQuestion() +
|
||||||
|
", questionNumber=" +
|
||||||
|
this.getQuestionNumber() +
|
||||||
|
", answers=" +
|
||||||
|
this.getAnswers() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,8 +121,7 @@ public class ChecklistQuestion extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof ChecklistQuestion)) return false;
|
if (!(o instanceof ChecklistQuestion)) return false;
|
||||||
final ChecklistQuestion other = (ChecklistQuestion) o;
|
final ChecklistQuestion other = (ChecklistQuestion) o;
|
||||||
return other.canEqual(this)
|
return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
|
||||||
&& Objects.equals(this.getId(), other.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
@ -124,4 +132,4 @@ public class ChecklistQuestion extends DomainObject {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(this.getId());
|
return Objects.hashCode(this.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import jakarta.transaction.Transactional;
|
|||||||
import se.su.dsv.scipro.system.JpaRepository;
|
import se.su.dsv.scipro.system.JpaRepository;
|
||||||
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public interface ChecklistQuestionRepo extends JpaRepository<ChecklistQuestion, Long>, QueryDslPredicateExecutor<ChecklistQuestion> {
|
public interface ChecklistQuestionRepo
|
||||||
}
|
extends JpaRepository<ChecklistQuestion, Long>, QueryDslPredicateExecutor<ChecklistQuestion> {}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.GenericRepo;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import se.su.dsv.scipro.system.GenericRepo;
|
||||||
|
|
||||||
|
public class ChecklistQuestionRepoImpl
|
||||||
|
extends GenericRepo<ChecklistQuestion, Long>
|
||||||
|
implements ChecklistQuestionRepo {
|
||||||
|
|
||||||
public class ChecklistQuestionRepoImpl extends GenericRepo<ChecklistQuestion, Long> implements ChecklistQuestionRepo {
|
|
||||||
@Inject
|
@Inject
|
||||||
public ChecklistQuestionRepoImpl(Provider<EntityManager> em) {
|
public ChecklistQuestionRepoImpl(Provider<EntityManager> em) {
|
||||||
super(em, ChecklistQuestion.class, QChecklistQuestion.checklistQuestion);
|
super(em, ChecklistQuestion.class, QChecklistQuestion.checklistQuestion);
|
||||||
|
@ -5,7 +5,6 @@ import se.su.dsv.scipro.system.GenericService;
|
|||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
public interface ChecklistService extends GenericService<Checklist, Long> {
|
public interface ChecklistService extends GenericService<Checklist, Long> {
|
||||||
|
|
||||||
Long countAnswers(Project project, ChecklistAnswerEnum answer);
|
Long countAnswers(Project project, ChecklistAnswerEnum answer);
|
||||||
|
|
||||||
Long countUnanswered(Project project);
|
Long countUnanswered(Project project);
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import se.su.dsv.scipro.activityplan.QActivity;
|
|
||||||
import se.su.dsv.scipro.activityplan.QActivityPlan;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.util.Date;
|
||||||
|
import se.su.dsv.scipro.activityplan.QActivity;
|
||||||
|
import se.su.dsv.scipro.activityplan.QActivityPlan;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import java.util.Date;
|
public class ChecklistServiceImpl
|
||||||
|
extends AbstractServiceImpl<Checklist, Long>
|
||||||
|
implements ChecklistService {
|
||||||
|
|
||||||
public class ChecklistServiceImpl extends AbstractServiceImpl<Checklist, Long> implements ChecklistService {
|
|
||||||
@Inject
|
@Inject
|
||||||
public ChecklistServiceImpl(Provider<EntityManager> em) {
|
public ChecklistServiceImpl(Provider<EntityManager> em) {
|
||||||
super(em, Checklist.class, QChecklist.checklist);
|
super(em, Checklist.class, QChecklist.checklist);
|
||||||
@ -22,33 +23,34 @@ public class ChecklistServiceImpl extends AbstractServiceImpl<Checklist, Long> i
|
|||||||
@Override
|
@Override
|
||||||
public Long countAnswers(Project project, ChecklistAnswerEnum answer) {
|
public Long countAnswers(Project project, ChecklistAnswerEnum answer) {
|
||||||
return from(QActivityPlan.activityPlan)
|
return from(QActivityPlan.activityPlan)
|
||||||
.select(QChecklistAnswer.checklistAnswer.count())
|
.select(QChecklistAnswer.checklistAnswer.count())
|
||||||
.join(QActivityPlan.activityPlan.activities, QActivity.activity)
|
.join(QActivityPlan.activityPlan.activities, QActivity.activity)
|
||||||
.join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion)
|
.join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion)
|
||||||
.join(QChecklistQuestion.checklistQuestion.answers, QChecklistAnswer.checklistAnswer)
|
.join(QChecklistQuestion.checklistQuestion.answers, QChecklistAnswer.checklistAnswer)
|
||||||
.where(
|
.where(
|
||||||
QActivityPlan.activityPlan.project.eq(project),
|
QActivityPlan.activityPlan.project.eq(project),
|
||||||
QChecklistAnswer.checklistAnswer.answer.eq(answer))
|
QChecklistAnswer.checklistAnswer.answer.eq(answer)
|
||||||
.fetchFirst();
|
)
|
||||||
|
.fetchFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countUnanswered(Project project) {
|
public Long countUnanswered(Project project) {
|
||||||
long questions = from(QActivityPlan.activityPlan)
|
long questions = from(QActivityPlan.activityPlan)
|
||||||
.select(QChecklistQuestion.checklistQuestion.count())
|
.select(QChecklistQuestion.checklistQuestion.count())
|
||||||
.join(QActivityPlan.activityPlan.activities, QActivity.activity)
|
.join(QActivityPlan.activityPlan.activities, QActivity.activity)
|
||||||
.join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion)
|
.join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion)
|
||||||
.where(QActivityPlan.activityPlan.project.eq(project))
|
.where(QActivityPlan.activityPlan.project.eq(project))
|
||||||
.fetchFirst();
|
.fetchFirst();
|
||||||
questions = questions * project.getProjectParticipants().size();
|
questions = questions * project.getProjectParticipants().size();
|
||||||
|
|
||||||
long answers = from(QActivityPlan.activityPlan)
|
long answers = from(QActivityPlan.activityPlan)
|
||||||
.select(QChecklistAnswer.checklistAnswer.count())
|
.select(QChecklistAnswer.checklistAnswer.count())
|
||||||
.join(QActivityPlan.activityPlan.activities, QActivity.activity)
|
.join(QActivityPlan.activityPlan.activities, QActivity.activity)
|
||||||
.join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion)
|
.join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion)
|
||||||
.join(QChecklistQuestion.checklistQuestion.answers, QChecklistAnswer.checklistAnswer)
|
.join(QChecklistQuestion.checklistQuestion.answers, QChecklistAnswer.checklistAnswer)
|
||||||
.where(QActivityPlan.activityPlan.project.eq(project))
|
.where(QActivityPlan.activityPlan.project.eq(project))
|
||||||
.fetchFirst();
|
.fetchFirst();
|
||||||
|
|
||||||
return questions - answers;
|
return questions - answers;
|
||||||
}
|
}
|
||||||
@ -64,4 +66,4 @@ public class ChecklistServiceImpl extends AbstractServiceImpl<Checklist, Long> i
|
|||||||
checklist.getUserLastOpenDate().put(user, new Date());
|
checklist.getUserLastOpenDate().put(user, new Date());
|
||||||
return save(checklist);
|
return save(checklist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,19 +13,19 @@ import jakarta.persistence.JoinTable;
|
|||||||
import jakarta.persistence.ManyToMany;
|
import jakarta.persistence.ManyToMany;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "checklist_template")
|
@Table(name = "checklist_template")
|
||||||
public class ChecklistTemplate extends DomainObject {
|
public class ChecklistTemplate extends DomainObject {
|
||||||
|
|
||||||
public static final int MIN_TITLE_LENGTH = 3;
|
public static final int MIN_TITLE_LENGTH = 3;
|
||||||
public static final int DEFAULT_TEMPLATE_NUMBER = 999;
|
public static final int DEFAULT_TEMPLATE_NUMBER = 999;
|
||||||
|
|
||||||
@ -46,8 +46,10 @@ public class ChecklistTemplate extends DomainObject {
|
|||||||
private int templateNumber = DEFAULT_TEMPLATE_NUMBER;
|
private int templateNumber = DEFAULT_TEMPLATE_NUMBER;
|
||||||
|
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
@CollectionTable(name = "checklist_template_question",
|
@CollectionTable(
|
||||||
joinColumns = @JoinColumn(name = "checklist_template_id"))
|
name = "checklist_template_question",
|
||||||
|
joinColumns = @JoinColumn(name = "checklist_template_id")
|
||||||
|
)
|
||||||
@Column(name = "question")
|
@Column(name = "question")
|
||||||
private List<String> questions = new ArrayList<>(1);
|
private List<String> questions = new ArrayList<>(1);
|
||||||
|
|
||||||
@ -56,20 +58,25 @@ public class ChecklistTemplate extends DomainObject {
|
|||||||
private User creator;
|
private User creator;
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "checklist_template_checklist_category",
|
@JoinTable(
|
||||||
joinColumns = @JoinColumn(name = "checklist_template_id", referencedColumnName = "id"),
|
name = "checklist_template_checklist_category",
|
||||||
inverseJoinColumns = @JoinColumn(name = "checklist_category_id", referencedColumnName = "id"))
|
joinColumns = @JoinColumn(name = "checklist_template_id", referencedColumnName = "id"),
|
||||||
|
inverseJoinColumns = @JoinColumn(
|
||||||
|
name = "checklist_category_id",
|
||||||
|
referencedColumnName = "id"
|
||||||
|
)
|
||||||
|
)
|
||||||
private List<ChecklistCategory> categories = new ArrayList<>();
|
private List<ChecklistCategory> categories = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "checklist_template_project_type",
|
@JoinTable(
|
||||||
joinColumns = {@JoinColumn(name = "checklist_template_id")},
|
name = "checklist_template_project_type",
|
||||||
inverseJoinColumns = {@JoinColumn(name = "project_type_id")})
|
joinColumns = { @JoinColumn(name = "checklist_template_id") },
|
||||||
|
inverseJoinColumns = { @JoinColumn(name = "project_type_id") }
|
||||||
|
)
|
||||||
private Collection<ProjectType> projectTypes = new HashSet<>();
|
private Collection<ProjectType> projectTypes = new HashSet<>();
|
||||||
|
|
||||||
public ChecklistTemplate() {
|
public ChecklistTemplate() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChecklistTemplate(String name, User creator) {
|
public ChecklistTemplate(String name, User creator) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -84,7 +91,7 @@ public class ChecklistTemplate extends DomainObject {
|
|||||||
questions.add(question);
|
questions.add(question);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearQuestions(){
|
public void clearQuestions() {
|
||||||
questions.clear();
|
questions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +158,25 @@ public class ChecklistTemplate extends DomainObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ChecklistTemplate(id=" + this.getId() + ", name=" + this.getName() + ", description=" + this.getDescription() + ", templateNumber=" + this.getTemplateNumber() + ", questions=" + this.getQuestions() + ", creator=" + this.getCreator() + ", categories=" + this.getCategories() + ", projectTypes=" + this.getProjectTypes() + ")";
|
return (
|
||||||
|
"ChecklistTemplate(id=" +
|
||||||
|
this.getId() +
|
||||||
|
", name=" +
|
||||||
|
this.getName() +
|
||||||
|
", description=" +
|
||||||
|
this.getDescription() +
|
||||||
|
", templateNumber=" +
|
||||||
|
this.getTemplateNumber() +
|
||||||
|
", questions=" +
|
||||||
|
this.getQuestions() +
|
||||||
|
", creator=" +
|
||||||
|
this.getCreator() +
|
||||||
|
", categories=" +
|
||||||
|
this.getCategories() +
|
||||||
|
", projectTypes=" +
|
||||||
|
this.getProjectTypes() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -159,8 +184,7 @@ public class ChecklistTemplate extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof ChecklistTemplate)) return false;
|
if (!(o instanceof ChecklistTemplate)) return false;
|
||||||
final ChecklistTemplate other = (ChecklistTemplate) o;
|
final ChecklistTemplate other = (ChecklistTemplate) o;
|
||||||
return other.canEqual(this)
|
return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
|
||||||
&& Objects.equals(this.getId(), other.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
@ -171,4 +195,4 @@ public class ChecklistTemplate extends DomainObject {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(this.getId());
|
return Objects.hashCode(this.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
import se.su.dsv.scipro.system.FilteredService;
|
import se.su.dsv.scipro.system.FilteredService;
|
||||||
import se.su.dsv.scipro.system.GenericService;
|
import se.su.dsv.scipro.system.GenericService;
|
||||||
|
|
||||||
import java.util.List;
|
public interface ChecklistTemplateService
|
||||||
|
extends
|
||||||
public interface ChecklistTemplateService extends GenericService<ChecklistTemplate, Long>, FilteredService<ChecklistTemplate, Long, String> {
|
GenericService<ChecklistTemplate, Long>, FilteredService<ChecklistTemplate, Long, String> {
|
||||||
void upChecklistTemplate(ChecklistTemplate checklistTemplate);
|
void upChecklistTemplate(ChecklistTemplate checklistTemplate);
|
||||||
void downChecklistTemplate(ChecklistTemplate checklistTemplate);
|
void downChecklistTemplate(ChecklistTemplate checklistTemplate);
|
||||||
void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate);
|
void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate);
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
|
||||||
import jakarta.inject.Provider;
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.querydsl.core.types.dsl.Expressions.allOf;
|
import static com.querydsl.core.types.dsl.Expressions.allOf;
|
||||||
|
|
||||||
public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistTemplate,Long> implements ChecklistTemplateService {
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import jakarta.inject.Provider;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.util.List;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
|
|
||||||
|
public class ChecklistTemplateServiceImpl
|
||||||
|
extends AbstractServiceImpl<ChecklistTemplate, Long>
|
||||||
|
implements ChecklistTemplateService {
|
||||||
|
|
||||||
public static final String PEER = "Peer";
|
public static final String PEER = "Peer";
|
||||||
|
|
||||||
@ -25,20 +26,27 @@ public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistT
|
|||||||
@Override
|
@Override
|
||||||
public List<ChecklistTemplate> findAll(String filterString, Pageable pageable) {
|
public List<ChecklistTemplate> findAll(String filterString, Pageable pageable) {
|
||||||
String filter = filterString == null ? "" : filterString;
|
String filter = filterString == null ? "" : filterString;
|
||||||
return findAll(filterStringIsCreatorName(filter).or(filterStringIsChecklistTemplateName(filter)), pageable);
|
return findAll(
|
||||||
|
filterStringIsCreatorName(filter).or(filterStringIsChecklistTemplateName(filter)),
|
||||||
|
pageable
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long count(String filterString) {
|
public long count(String filterString) {
|
||||||
String filter = filterString == null ? "" : filterString;
|
String filter = filterString == null ? "" : filterString;
|
||||||
return count(filterStringIsCreatorName(filter).or(filterStringIsChecklistTemplateName(filter)));
|
return count(
|
||||||
|
filterStringIsCreatorName(filter).or(filterStringIsChecklistTemplateName(filter))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void upChecklistTemplate(ChecklistTemplate checklistTemplate) {
|
public void upChecklistTemplate(ChecklistTemplate checklistTemplate) {
|
||||||
if (findByTemplateNumber(checklistTemplate.getTemplateNumber() + 1) != null) {
|
if (findByTemplateNumber(checklistTemplate.getTemplateNumber() + 1) != null) {
|
||||||
ChecklistTemplate downChecklistTemplate = findByTemplateNumber(checklistTemplate.getTemplateNumber() + 1);
|
ChecklistTemplate downChecklistTemplate = findByTemplateNumber(
|
||||||
|
checklistTemplate.getTemplateNumber() + 1
|
||||||
|
);
|
||||||
downChecklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber());
|
downChecklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber());
|
||||||
checklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber() + 1);
|
checklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber() + 1);
|
||||||
save(downChecklistTemplate);
|
save(downChecklistTemplate);
|
||||||
@ -54,7 +62,9 @@ public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistT
|
|||||||
@Override
|
@Override
|
||||||
public void downChecklistTemplate(ChecklistTemplate checklistTemplate) {
|
public void downChecklistTemplate(ChecklistTemplate checklistTemplate) {
|
||||||
if (findByTemplateNumber(checklistTemplate.getTemplateNumber() - 1) != null) {
|
if (findByTemplateNumber(checklistTemplate.getTemplateNumber() - 1) != null) {
|
||||||
ChecklistTemplate upChecklistTemplate = findByTemplateNumber(checklistTemplate.getTemplateNumber() - 1);
|
ChecklistTemplate upChecklistTemplate = findByTemplateNumber(
|
||||||
|
checklistTemplate.getTemplateNumber() - 1
|
||||||
|
);
|
||||||
upChecklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber());
|
upChecklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber());
|
||||||
checklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber() - 1);
|
checklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber() - 1);
|
||||||
save(upChecklistTemplate);
|
save(upChecklistTemplate);
|
||||||
@ -65,7 +75,11 @@ public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistT
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate) {
|
public void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate) {
|
||||||
for (ChecklistTemplate clt : findAll(QChecklistTemplate.checklistTemplate.templateNumber.gt(checklistTemplate.getTemplateNumber()))) {
|
for (ChecklistTemplate clt : findAll(
|
||||||
|
QChecklistTemplate.checklistTemplate.templateNumber.gt(
|
||||||
|
checklistTemplate.getTemplateNumber()
|
||||||
|
)
|
||||||
|
)) {
|
||||||
clt.setTemplateNumber(clt.getTemplateNumber() - 1);
|
clt.setTemplateNumber(clt.getTemplateNumber() - 1);
|
||||||
}
|
}
|
||||||
delete(checklistTemplate);
|
delete(checklistTemplate);
|
||||||
@ -73,15 +87,21 @@ public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistT
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ChecklistTemplate> findPeerRequestChecklists(final Project project) {
|
public List<ChecklistTemplate> findPeerRequestChecklists(final Project project) {
|
||||||
return findAll(allOf(
|
return findAll(
|
||||||
QChecklistTemplate.checklistTemplate.projectTypes.any().eq(project.getProjectType()),
|
allOf(
|
||||||
|
QChecklistTemplate.checklistTemplate.projectTypes
|
||||||
|
.any()
|
||||||
|
.eq(project.getProjectType()),
|
||||||
QChecklistTemplate.checklistTemplate.categories.any().categoryName.eq(PEER)
|
QChecklistTemplate.checklistTemplate.categories.any().categoryName.eq(PEER)
|
||||||
));
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ChecklistTemplate> findByProject(Project project) {
|
public List<ChecklistTemplate> findByProject(Project project) {
|
||||||
return findAll(QChecklistTemplate.checklistTemplate.projectTypes.any().eq(project.getProjectType()));
|
return findAll(
|
||||||
|
QChecklistTemplate.checklistTemplate.projectTypes.any().eq(project.getProjectType())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,7 +110,9 @@ public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistT
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BooleanExpression filterStringIsCreatorName(String filterString) {
|
public static BooleanExpression filterStringIsCreatorName(String filterString) {
|
||||||
return QChecklistTemplate.checklistTemplate.creator.firstName.contains(filterString).or(QChecklistTemplate.checklistTemplate.creator.lastName.contains(filterString));
|
return QChecklistTemplate.checklistTemplate.creator.firstName
|
||||||
|
.contains(filterString)
|
||||||
|
.or(QChecklistTemplate.checklistTemplate.creator.lastName.contains(filterString));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BooleanExpression filterStringIsChecklistTemplateName(String filterString) {
|
public static BooleanExpression filterStringIsChecklistTemplateName(String filterString) {
|
||||||
|
@ -5,5 +5,4 @@ public class ExternalImportException extends RuntimeException {
|
|||||||
public ExternalImportException(Throwable e) {
|
public ExternalImportException(Throwable e) {
|
||||||
super(e);
|
super(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package se.su.dsv.scipro.daisyExternal.http;
|
package se.su.dsv.scipro.daisyExternal.http;
|
||||||
|
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
import se.su.dsv.scipro.io.dto.*;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import se.su.dsv.scipro.io.dto.*;
|
||||||
|
|
||||||
public interface DaisyAPI {
|
public interface DaisyAPI {
|
||||||
Set<ProjectParticipant> getContributors(Integer projectId);
|
Set<ProjectParticipant> getContributors(Integer projectId);
|
||||||
@ -74,7 +73,11 @@ public interface DaisyAPI {
|
|||||||
|
|
||||||
PublishingConsent getPublishingConsent(int projectId, int personId);
|
PublishingConsent getPublishingConsent(int projectId, int personId);
|
||||||
|
|
||||||
boolean setPublishingConsent(int projectId, int personId, PublishingConsentLevel publishingConsentLevel);
|
boolean setPublishingConsent(
|
||||||
|
int projectId,
|
||||||
|
int personId,
|
||||||
|
PublishingConsentLevel publishingConsentLevel
|
||||||
|
);
|
||||||
|
|
||||||
List<ResearchSubject> getNationalResearchSubjects(int organisationId);
|
List<ResearchSubject> getNationalResearchSubjects(int organisationId);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package se.su.dsv.scipro.daisyExternal.http;
|
package se.su.dsv.scipro.daisyExternal.http;
|
||||||
|
|
||||||
|
import static jakarta.ws.rs.client.Entity.xml;
|
||||||
|
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import jakarta.inject.Named;
|
||||||
import jakarta.ws.rs.NotFoundException;
|
import jakarta.ws.rs.NotFoundException;
|
||||||
import jakarta.ws.rs.ProcessingException;
|
import jakarta.ws.rs.ProcessingException;
|
||||||
import jakarta.ws.rs.client.Client;
|
import jakarta.ws.rs.client.Client;
|
||||||
@ -10,16 +14,11 @@ import jakarta.ws.rs.client.WebTarget;
|
|||||||
import jakarta.ws.rs.core.GenericType;
|
import jakarta.ws.rs.core.GenericType;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
|
||||||
import se.su.dsv.scipro.io.dto.*;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
|
||||||
import jakarta.inject.Named;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
||||||
import static jakarta.ws.rs.client.Entity.xml;
|
import se.su.dsv.scipro.io.dto.*;
|
||||||
|
|
||||||
public class DaisyAPIImpl implements DaisyAPI {
|
public class DaisyAPIImpl implements DaisyAPI {
|
||||||
|
|
||||||
@ -44,220 +43,208 @@ public class DaisyAPIImpl implements DaisyAPI {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DaisyAPIImpl(
|
public DaisyAPIImpl(
|
||||||
@Named("daisy.api.url") final String baseUrl,
|
@Named("daisy.api.url") final String baseUrl,
|
||||||
@Named("daisy.api.username") final String user,
|
@Named("daisy.api.username") final String user,
|
||||||
@Named("daisy.api.password") final String password) {
|
@Named("daisy.api.password") final String password
|
||||||
|
) {
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
this.client = ClientBuilder.newClient()
|
this.client = ClientBuilder.newClient()
|
||||||
.register(HttpAuthenticationFeature.basic(user, password));
|
.register(HttpAuthenticationFeature.basic(user, password));
|
||||||
this.objectFactory = new ObjectFactory();
|
this.objectFactory = new ObjectFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<ProjectParticipant> getContributors(Integer projectId) {
|
public Set<ProjectParticipant> getContributors(Integer projectId) {
|
||||||
return thesis()
|
return thesis()
|
||||||
.path(String.valueOf(projectId))
|
.path(String.valueOf(projectId))
|
||||||
.path(CONTRIBUTOR)
|
.path(CONTRIBUTOR)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<AuthorProjectParticipant> getAuthors(Integer projectId) {
|
public Set<AuthorProjectParticipant> getAuthors(Integer projectId) {
|
||||||
return thesis()
|
return thesis()
|
||||||
.path(String.valueOf(projectId))
|
.path(String.valueOf(projectId))
|
||||||
.path(AUTHOR)
|
.path(AUTHOR)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Thesis> getProjects(Integer personId) {
|
public Set<Thesis> getProjects(Integer personId) {
|
||||||
return person()
|
return person()
|
||||||
.path(String.valueOf(personId))
|
.path(String.valueOf(personId))
|
||||||
.path(THESES)
|
.path(THESES)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Unit> getSubUnits(Integer unitId) {
|
public Set<Unit> getSubUnits(Integer unitId) {
|
||||||
return units()
|
return units()
|
||||||
.path(String.valueOf(unitId))
|
.path(String.valueOf(unitId))
|
||||||
.path(SUBUNITS)
|
.path(SUBUNITS)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UserName> getUsernames(Integer personId) {
|
public Set<UserName> getUsernames(Integer personId) {
|
||||||
return person()
|
return person()
|
||||||
.path(String.valueOf(personId))
|
.path(String.valueOf(personId))
|
||||||
.path(USERNAMES)
|
.path(USERNAMES)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ResearchArea> getResearchAreas(Integer personId) {
|
public List<ResearchArea> getResearchAreas(Integer personId) {
|
||||||
return person()
|
return person()
|
||||||
.path(String.valueOf(personId))
|
.path(String.valueOf(personId))
|
||||||
.path(RESEARCH_AREAS)
|
.path(RESEARCH_AREAS)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Person> getSupervisors(Integer unitId) {
|
public List<Person> getSupervisors(Integer unitId) {
|
||||||
return units()
|
return units()
|
||||||
.path(String.valueOf(unitId))
|
.path(String.valueOf(unitId))
|
||||||
.path(SUPERVISORS)
|
.path(SUPERVISORS)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Person> findPersonById(Integer id) {
|
public Optional<Person> findPersonById(Integer id) {
|
||||||
Response response = person()
|
Response response = person()
|
||||||
.path(String.valueOf(id))
|
.path(String.valueOf(id))
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(Response.class);
|
.get(Response.class);
|
||||||
return response.getStatus() == 200
|
return response.getStatus() == 200
|
||||||
? Optional.of(response.readEntity(Person.class))
|
? Optional.of(response.readEntity(Person.class))
|
||||||
: Optional.empty();
|
: Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Person> findByUsername(String userName) {
|
public Optional<Person> findByUsername(String userName) {
|
||||||
Response response = person()
|
Response response = person()
|
||||||
.path(USERNAME)
|
.path(USERNAME)
|
||||||
.path(userName)
|
.path(userName)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(Response.class);
|
.get(Response.class);
|
||||||
return response.getStatus() == 200
|
return response.getStatus() == 200
|
||||||
? Optional.of(response.readEntity(Person.class))
|
? Optional.of(response.readEntity(Person.class))
|
||||||
: Optional.empty();
|
: Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response addContributor(Integer projectIdentifier, ProjectParticipant contributor) {
|
public Response addContributor(Integer projectIdentifier, ProjectParticipant contributor) {
|
||||||
return thesis()
|
return thesis()
|
||||||
.path(String.valueOf(projectIdentifier))
|
.path(String.valueOf(projectIdentifier))
|
||||||
.path(CONTRIBUTOR)
|
.path(CONTRIBUTOR)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.post(xml(objectFactory.createProjectParticipant(contributor)));
|
.post(xml(objectFactory.createProjectParticipant(contributor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteThesisPerson(Integer projectId, Integer personId) {
|
public void deleteThesisPerson(Integer projectId, Integer personId) {
|
||||||
thesis()
|
thesis()
|
||||||
.path(String.valueOf(projectId))
|
.path(String.valueOf(projectId))
|
||||||
.path(PERSON)
|
.path(PERSON)
|
||||||
.path(String.valueOf(personId))
|
.path(String.valueOf(personId))
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.delete();
|
.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response createProject(ThesisToBeCreated project) {
|
public Response createProject(ThesisToBeCreated project) {
|
||||||
return thesis()
|
return thesis().request(MediaType.APPLICATION_XML_TYPE).post(xml(project));
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
|
||||||
.post(xml(project));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response addAuthor(Integer projectId, AddThesisAuthor addThesisAuthor) {
|
public Response addAuthor(Integer projectId, AddThesisAuthor addThesisAuthor) {
|
||||||
return thesis()
|
return thesis()
|
||||||
.path(String.valueOf(projectId))
|
.path(String.valueOf(projectId))
|
||||||
.path("author")
|
.path("author")
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.post(xml(addThesisAuthor));
|
.post(xml(addThesisAuthor));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response deleteProject(Integer projectId) {
|
public Response deleteProject(Integer projectId) {
|
||||||
return thesis()
|
return thesis()
|
||||||
.path(String.valueOf(projectId))
|
.path(String.valueOf(projectId))
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.delete();
|
.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response getStudent(Integer id) {
|
public Response getStudent(Integer id) {
|
||||||
return student()
|
return student().path(String.valueOf(id)).request(MediaType.APPLICATION_XML_TYPE).get();
|
||||||
.path(String.valueOf(id))
|
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
|
||||||
.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Program getProgram(Integer id) {
|
public Program getProgram(Integer id) {
|
||||||
return program()
|
return program()
|
||||||
.path(String.valueOf(id))
|
.path(String.valueOf(id))
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(Program.class);
|
.get(Program.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Thesis> getThesis(Integer projectIdentifier) {
|
public Optional<Thesis> getThesis(Integer projectIdentifier) {
|
||||||
Response response = thesis()
|
Response response = thesis()
|
||||||
.path(String.valueOf(projectIdentifier))
|
.path(String.valueOf(projectIdentifier))
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(Response.class);
|
.get(Response.class);
|
||||||
return response.getStatus() == 200
|
return response.getStatus() == 200
|
||||||
? Optional.of(response.readEntity(Thesis.class))
|
? Optional.of(response.readEntity(Thesis.class))
|
||||||
: Optional.empty();
|
: Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateThesis(final Integer id, ThesisToBeUpdated thesis) {
|
public void updateThesis(final Integer id, ThesisToBeUpdated thesis) {
|
||||||
thesis()
|
thesis().path(String.valueOf(id)).request().put(xml(thesis));
|
||||||
.path(String.valueOf(id))
|
|
||||||
.request()
|
|
||||||
.put(xml(thesis));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> getGradeForStudentInCourse(Long authorId, Integer courseId) {
|
public Optional<String> getGradeForStudentInCourse(Long authorId, Integer courseId) {
|
||||||
Response response = course()
|
Response response = course()
|
||||||
.path(String.valueOf(courseId))
|
.path(String.valueOf(courseId))
|
||||||
.path(STUDENT)
|
.path(STUDENT)
|
||||||
.path(String.valueOf(authorId))
|
.path(String.valueOf(authorId))
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get();
|
.get();
|
||||||
return response.getStatus() == 200
|
return response.getStatus() == 200
|
||||||
? Optional.ofNullable(response.readEntity(String.class))
|
? Optional.ofNullable(response.readEntity(String.class))
|
||||||
: Optional.empty();
|
: Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Person> findByPersonnummer(final String personnummer) {
|
public List<Person> findByPersonnummer(final String personnummer) {
|
||||||
return person()
|
return person()
|
||||||
.queryParam("personnummer", personnummer)
|
.queryParam("personnummer", personnummer)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PhotoResult getPhoto(final Integer personId, final int requesterId, final boolean alwaysShow) {
|
public PhotoResult getPhoto(
|
||||||
|
final Integer personId,
|
||||||
|
final int requesterId,
|
||||||
|
final boolean alwaysShow
|
||||||
|
) {
|
||||||
final Response response;
|
final Response response;
|
||||||
try {
|
try {
|
||||||
response = person()
|
response = person()
|
||||||
.path(String.valueOf(personId))
|
.path(String.valueOf(personId))
|
||||||
.path("photo")
|
.path("photo")
|
||||||
.queryParam("show", alwaysShow)
|
.queryParam("show", alwaysShow)
|
||||||
.request()
|
.request()
|
||||||
.header("X-User-Id", requesterId)
|
.header("X-User-Id", requesterId)
|
||||||
.get();
|
.get();
|
||||||
} catch (ProcessingException e) {
|
} catch (ProcessingException e) {
|
||||||
return new PhotoResult.Missing();
|
return new PhotoResult.Missing();
|
||||||
}
|
}
|
||||||
@ -279,10 +266,10 @@ public class DaisyAPIImpl implements DaisyAPI {
|
|||||||
@Override
|
@Override
|
||||||
public Optional<ThesisPublication> getPublication(final long projectId) {
|
public Optional<ThesisPublication> getPublication(final long projectId) {
|
||||||
final Response response = thesis()
|
final Response response = thesis()
|
||||||
.path(Long.toString(projectId))
|
.path(Long.toString(projectId))
|
||||||
.path("publication")
|
.path("publication")
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get();
|
.get();
|
||||||
switch (response.getStatus()) {
|
switch (response.getStatus()) {
|
||||||
case 200:
|
case 200:
|
||||||
return Optional.of(response.readEntity(ThesisPublication.class));
|
return Optional.of(response.readEntity(ThesisPublication.class));
|
||||||
@ -297,55 +284,60 @@ public class DaisyAPIImpl implements DaisyAPI {
|
|||||||
@Override
|
@Override
|
||||||
public boolean sendPublication(final long projectId, final ThesisPublication publication) {
|
public boolean sendPublication(final long projectId, final ThesisPublication publication) {
|
||||||
final Response response = thesis()
|
final Response response = thesis()
|
||||||
.path(Long.toString(projectId))
|
.path(Long.toString(projectId))
|
||||||
.path("publication")
|
.path("publication")
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.put(Entity.xml(publication));
|
.put(Entity.xml(publication));
|
||||||
return response.getStatus() == 200;
|
return response.getStatus() == 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendPublicationFile(final long projectId, final String filename, final InputStream data) {
|
public boolean sendPublicationFile(
|
||||||
|
final long projectId,
|
||||||
|
final String filename,
|
||||||
|
final InputStream data
|
||||||
|
) {
|
||||||
final String asciiOnlyFilename = asciify(filename);
|
final String asciiOnlyFilename = asciify(filename);
|
||||||
final Response response = thesis()
|
final Response response = thesis()
|
||||||
.path(Long.toString(projectId))
|
.path(Long.toString(projectId))
|
||||||
.path("publication")
|
.path("publication")
|
||||||
.path("file")
|
.path("file")
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.header("X-Filename", asciiOnlyFilename)
|
.header("X-Filename", asciiOnlyFilename)
|
||||||
.put(Entity.entity(data, "application/pdf"));
|
.put(Entity.entity(data, "application/pdf"));
|
||||||
return response.getStatus() == 200;
|
return response.getStatus() == 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String asciify(String str) {
|
private static String asciify(String str) {
|
||||||
return str
|
return str
|
||||||
.replace('Å', 'A')
|
.replace('Å', 'A')
|
||||||
.replace('Ä', 'A')
|
.replace('Ä', 'A')
|
||||||
.replace('Ö', 'O')
|
.replace('Ö', 'O')
|
||||||
.replace('å', 'a')
|
.replace('å', 'a')
|
||||||
.replace('ä', 'a')
|
.replace('ä', 'a')
|
||||||
.replace('ö', 'o')
|
.replace('ö', 'o')
|
||||||
.replaceAll("\\P{ASCII}", ""); // Removes all remaining non-ASCII characters
|
.replaceAll("\\P{ASCII}", ""); // Removes all remaining non-ASCII characters
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Program> getPrograms(final Integer responsibleDepartmentId) {
|
public List<Program> getPrograms(final Integer responsibleDepartmentId) {
|
||||||
return program()
|
return program()
|
||||||
.queryParam("responsibleDepartment", responsibleDepartmentId)
|
.queryParam("responsibleDepartment", responsibleDepartmentId)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProgramAdmission> getProgramAdmissions(final Program program, final Semester admissionSemester) {
|
public List<ProgramAdmission> getProgramAdmissions(
|
||||||
|
final Program program,
|
||||||
|
final Semester admissionSemester
|
||||||
|
) {
|
||||||
return program()
|
return program()
|
||||||
.path(String.valueOf(program.getId()))
|
.path(String.valueOf(program.getId()))
|
||||||
.path("admissions")
|
.path("admissions")
|
||||||
.queryParam("admissionSemester", admissionSemester.getId())
|
.queryParam("admissionSemester", admissionSemester.getId())
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -353,23 +345,21 @@ public class DaisyAPIImpl implements DaisyAPI {
|
|||||||
// have to pre-format the date parameter due to weird api handling of dates
|
// have to pre-format the date parameter due to weird api handling of dates
|
||||||
final String sinceParameter = new SimpleDateFormat("yyyy-MM-dd").format(since);
|
final String sinceParameter = new SimpleDateFormat("yyyy-MM-dd").format(since);
|
||||||
return thesis()
|
return thesis()
|
||||||
.path("rejections")
|
.path("rejections")
|
||||||
.queryParam("since", sinceParameter)
|
.queryParam("since", sinceParameter)
|
||||||
// must be XML due to api date-formatting in json
|
// must be XML due to api date-formatting in json
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StudentProgramAdmission> getProgramAdmissionsForStudent(final int studentId) {
|
public List<StudentProgramAdmission> getProgramAdmissionsForStudent(final int studentId) {
|
||||||
try {
|
try {
|
||||||
return student()
|
return student()
|
||||||
.path(Integer.toString(studentId))
|
.path(Integer.toString(studentId))
|
||||||
.path("programAdmissions")
|
.path("programAdmissions")
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
} catch (NotFoundException ignored) {
|
} catch (NotFoundException ignored) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -379,11 +369,10 @@ public class DaisyAPIImpl implements DaisyAPI {
|
|||||||
public List<CourseRegistration> getCourseRegistrationsForStudent(final int studentId) {
|
public List<CourseRegistration> getCourseRegistrationsForStudent(final int studentId) {
|
||||||
try {
|
try {
|
||||||
return student()
|
return student()
|
||||||
.path(Integer.toString(studentId))
|
.path(Integer.toString(studentId))
|
||||||
.path("courseRegistrations")
|
.path("courseRegistrations")
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {
|
.get(new GenericType<>() {});
|
||||||
});
|
|
||||||
} catch (NotFoundException ignored) {
|
} catch (NotFoundException ignored) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -392,15 +381,16 @@ public class DaisyAPIImpl implements DaisyAPI {
|
|||||||
@Override
|
@Override
|
||||||
public List<Employee> listEmployees(int departmentId) {
|
public List<Employee> listEmployees(int departmentId) {
|
||||||
return target()
|
return target()
|
||||||
.path("employee")
|
.path("employee")
|
||||||
.queryParam("department", departmentId)
|
.queryParam("department", departmentId)
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {});
|
.get(new GenericType<>() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrganisationalUnit orgunit(final int unitId) {
|
public OrganisationalUnit orgunit(final int unitId) {
|
||||||
return () -> target()
|
return () ->
|
||||||
|
target()
|
||||||
.path("orgunit")
|
.path("orgunit")
|
||||||
.path(Integer.toString(unitId))
|
.path(Integer.toString(unitId))
|
||||||
.path("researchAreas")
|
.path("researchAreas")
|
||||||
@ -411,22 +401,26 @@ public class DaisyAPIImpl implements DaisyAPI {
|
|||||||
@Override
|
@Override
|
||||||
public PublishingConsent getPublishingConsent(int projectId, int personId) {
|
public PublishingConsent getPublishingConsent(int projectId, int personId) {
|
||||||
return thesis()
|
return thesis()
|
||||||
.path(Integer.toString(projectId))
|
.path(Integer.toString(projectId))
|
||||||
.path("author")
|
.path("author")
|
||||||
.path(Integer.toString(personId))
|
.path(Integer.toString(personId))
|
||||||
.path("publishingConsent")
|
.path("publishingConsent")
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(PublishingConsent.class);
|
.get(PublishingConsent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setPublishingConsent(int projectId, int personId, PublishingConsentLevel publishingConsentLevel) {
|
public boolean setPublishingConsent(
|
||||||
|
int projectId,
|
||||||
|
int personId,
|
||||||
|
PublishingConsentLevel publishingConsentLevel
|
||||||
|
) {
|
||||||
final Invocation.Builder request = thesis()
|
final Invocation.Builder request = thesis()
|
||||||
.path(Integer.toString(projectId))
|
.path(Integer.toString(projectId))
|
||||||
.path("author")
|
.path("author")
|
||||||
.path(Integer.toString(personId))
|
.path(Integer.toString(personId))
|
||||||
.path("publishingConsent")
|
.path("publishingConsent")
|
||||||
.request(MediaType.APPLICATION_XML_TYPE);
|
.request(MediaType.APPLICATION_XML_TYPE);
|
||||||
|
|
||||||
// For some reason XML does not work
|
// For some reason XML does not work
|
||||||
try (Response response = request.post(Entity.json(publishingConsentLevel))) {
|
try (Response response = request.post(Entity.json(publishingConsentLevel))) {
|
||||||
@ -437,44 +431,37 @@ public class DaisyAPIImpl implements DaisyAPI {
|
|||||||
@Override
|
@Override
|
||||||
public List<ResearchSubject> getNationalResearchSubjects(int organisationId) {
|
public List<ResearchSubject> getNationalResearchSubjects(int organisationId) {
|
||||||
return units()
|
return units()
|
||||||
.path(Integer.toString(organisationId))
|
.path(Integer.toString(organisationId))
|
||||||
.path("nationalSubjectCategories")
|
.path("nationalSubjectCategories")
|
||||||
.request(MediaType.APPLICATION_XML_TYPE)
|
.request(MediaType.APPLICATION_XML_TYPE)
|
||||||
.get(new GenericType<>() {});
|
.get(new GenericType<>() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebTarget program() {
|
private WebTarget program() {
|
||||||
return target()
|
return target().path(PROGRAM);
|
||||||
.path(PROGRAM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebTarget student() {
|
private WebTarget student() {
|
||||||
return target()
|
return target().path(STUDENT);
|
||||||
.path(STUDENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebTarget thesis() {
|
private WebTarget thesis() {
|
||||||
return target()
|
return target().path(THESIS);
|
||||||
.path(THESIS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebTarget units() {
|
private WebTarget units() {
|
||||||
return target()
|
return target().path(ORGUNIT);
|
||||||
.path(ORGUNIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebTarget person() {
|
private WebTarget person() {
|
||||||
return target()
|
return target().path(PERSON);
|
||||||
.path(PERSON);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebTarget course() {
|
private WebTarget course() {
|
||||||
return target()
|
return target().path(COURSE);
|
||||||
.path(COURSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebTarget target() {
|
private WebTarget target() {
|
||||||
return client
|
return client.target(baseUrl);
|
||||||
.target(baseUrl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package se.su.dsv.scipro.daisyExternal.http;
|
package se.su.dsv.scipro.daisyExternal.http;
|
||||||
|
|
||||||
import se.su.dsv.scipro.io.dto.ResearchArea;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import se.su.dsv.scipro.io.dto.ResearchArea;
|
||||||
|
|
||||||
public interface OrganisationalUnit {
|
public interface OrganisationalUnit {
|
||||||
List<ResearchArea> getResearchAreas();
|
List<ResearchArea> getResearchAreas();
|
||||||
|
@ -6,23 +6,38 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public abstract class PhotoResult {
|
public abstract class PhotoResult {
|
||||||
|
|
||||||
public abstract <X> X fold(final Supplier<X> missing, final Supplier<X> forbidden, final Function<InputStream, X> found);
|
public abstract <X> X fold(
|
||||||
|
final Supplier<X> missing,
|
||||||
|
final Supplier<X> forbidden,
|
||||||
|
final Function<InputStream, X> found
|
||||||
|
);
|
||||||
|
|
||||||
public static class Missing extends PhotoResult {
|
public static class Missing extends PhotoResult {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> X fold(final Supplier<X> missing, final Supplier<X> forbidden, final Function<InputStream, X> found) {
|
public <X> X fold(
|
||||||
|
final Supplier<X> missing,
|
||||||
|
final Supplier<X> forbidden,
|
||||||
|
final Function<InputStream, X> found
|
||||||
|
) {
|
||||||
return missing.get();
|
return missing.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Forbidden extends PhotoResult {
|
static class Forbidden extends PhotoResult {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> X fold(final Supplier<X> missing, final Supplier<X> forbidden, final Function<InputStream, X> found) {
|
public <X> X fold(
|
||||||
|
final Supplier<X> missing,
|
||||||
|
final Supplier<X> forbidden,
|
||||||
|
final Function<InputStream, X> found
|
||||||
|
) {
|
||||||
return forbidden.get();
|
return forbidden.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Found extends PhotoResult {
|
static class Found extends PhotoResult {
|
||||||
|
|
||||||
private final InputStream photo;
|
private final InputStream photo;
|
||||||
|
|
||||||
Found(final InputStream photo) {
|
Found(final InputStream photo) {
|
||||||
@ -30,9 +45,12 @@ public abstract class PhotoResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> X fold(final Supplier<X> missing, final Supplier<X> forbidden, final Function<InputStream, X> found) {
|
public <X> X fold(
|
||||||
|
final Supplier<X> missing,
|
||||||
|
final Supplier<X> forbidden,
|
||||||
|
final Function<InputStream, X> found
|
||||||
|
) {
|
||||||
return found.apply(photo);
|
return found.apply(photo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package se.su.dsv.scipro.daisyExternal.http;
|
package se.su.dsv.scipro.daisyExternal.http;
|
||||||
|
|
||||||
public abstract class Semester {
|
public abstract class Semester {
|
||||||
|
|
||||||
public static Semester spring(int year) {
|
public static Semester spring(int year) {
|
||||||
return new Spring(year);
|
return new Spring(year);
|
||||||
}
|
}
|
||||||
@ -17,6 +18,7 @@ public abstract class Semester {
|
|||||||
public abstract String toString();
|
public abstract String toString();
|
||||||
|
|
||||||
private static final class Spring extends Semester {
|
private static final class Spring extends Semester {
|
||||||
|
|
||||||
private final int year;
|
private final int year;
|
||||||
|
|
||||||
public Spring(final int year) {
|
public Spring(final int year) {
|
||||||
@ -35,6 +37,7 @@ public abstract class Semester {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class Autumn extends Semester {
|
private static final class Autumn extends Semester {
|
||||||
|
|
||||||
private final int year;
|
private final int year;
|
||||||
|
|
||||||
public Autumn(final int year) {
|
public Autumn(final int year) {
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package se.su.dsv.scipro.data.dataobjects;
|
package se.su.dsv.scipro.data.dataobjects;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
public class Member implements Serializable {
|
public class Member implements Serializable {
|
||||||
|
|
||||||
private final User user;
|
private final User user;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
AUTHOR {
|
AUTHOR {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@ -75,7 +75,7 @@ public class Member implements Serializable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "Individual milestone";
|
return "Individual milestone";
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
public Member(User user, Type type) {
|
public Member(User user, Type type) {
|
||||||
@ -96,9 +96,11 @@ public class Member implements Serializable {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof Member)) return false;
|
if (!(o instanceof Member)) return false;
|
||||||
final Member other = (Member) o;
|
final Member other = (Member) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& Objects.equals(this.getUser(), other.getUser())
|
other.canEqual(this) &&
|
||||||
&& Objects.equals(this.getType(), other.getType());
|
Objects.equals(this.getUser(), other.getUser()) &&
|
||||||
|
Objects.equals(this.getType(), other.getType())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
@ -112,6 +114,6 @@ public class Member implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Member(user=" + this.getUser() + ", type=" + this.getType() + ")";
|
return ("Member(user=" + this.getUser() + ", type=" + this.getType() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package se.su.dsv.scipro.data.enums;
|
package se.su.dsv.scipro.data.enums;
|
||||||
|
|
||||||
public enum DateStyle {
|
public enum DateStyle {
|
||||||
|
DATETIME("yyyy-MM-dd HH:mm"),
|
||||||
DATETIME("yyyy-MM-dd HH:mm"), DATE("yyyy-MM-dd"), TIME("HH:mm");
|
DATE("yyyy-MM-dd"),
|
||||||
|
TIME("HH:mm");
|
||||||
|
|
||||||
private final String format;
|
private final String format;
|
||||||
|
|
||||||
|
@ -1,27 +1,25 @@
|
|||||||
package se.su.dsv.scipro.data.enums;
|
package se.su.dsv.scipro.data.enums;
|
||||||
|
|
||||||
public enum MailChoice {
|
public enum MailChoice {
|
||||||
THESIS_SUPPORT("Thesis support"),
|
THESIS_SUPPORT("Thesis support"),
|
||||||
AUTHORS_ACTIVE_PROJECT("Authors with active projects"),
|
AUTHORS_ACTIVE_PROJECT("Authors with active projects"),
|
||||||
ACTIVE_SUPERVISORS("Head supervisors with active projects"),
|
ACTIVE_SUPERVISORS("Head supervisors with active projects"),
|
||||||
ACTIVE_CO_SUPERVISORS("Co-supervisors with active projects"),
|
ACTIVE_CO_SUPERVISORS("Co-supervisors with active projects"),
|
||||||
ACTIVE_REVIEWERS("Reviewers of active projects"),
|
ACTIVE_REVIEWERS("Reviewers of active projects"),
|
||||||
ALL_FOLLOWERS("All supervisors and reviewers of active projects"),
|
ALL_FOLLOWERS("All supervisors and reviewers of active projects"),
|
||||||
AUTHORS_SUBMITTED_IDEA("Authors with submitted ideas"),
|
AUTHORS_SUBMITTED_IDEA("Authors with submitted ideas"),
|
||||||
AUTHORS_MATCHED_IDEA("Authors with matched ideas"),
|
AUTHORS_MATCHED_IDEA("Authors with matched ideas"),
|
||||||
SUPERVISORS_MATCHED_IDEA("Supervisors with matched ideas"),
|
SUPERVISORS_MATCHED_IDEA("Supervisors with matched ideas"),
|
||||||
SUPERVISORS_SUBMITTED_IDEA("Supervisors with submitted ideas");
|
SUPERVISORS_SUBMITTED_IDEA("Supervisors with submitted ideas");
|
||||||
|
|
||||||
private String asString;
|
private String asString;
|
||||||
|
|
||||||
MailChoice(String asString) {
|
MailChoice(String asString) {
|
||||||
this.asString = asString;
|
this.asString = asString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return asString;
|
return asString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package se.su.dsv.scipro.data.facade;
|
package se.su.dsv.scipro.data.facade;
|
||||||
|
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
import se.su.dsv.scipro.data.enums.MailChoice;
|
import se.su.dsv.scipro.data.enums.MailChoice;
|
||||||
import se.su.dsv.scipro.generalsystemsettings.GeneralSystemSettingsService;
|
import se.su.dsv.scipro.generalsystemsettings.GeneralSystemSettingsService;
|
||||||
import se.su.dsv.scipro.mail.EmailRecipient;
|
import se.su.dsv.scipro.mail.EmailRecipient;
|
||||||
@ -15,40 +18,63 @@ import se.su.dsv.scipro.project.ProjectStatus;
|
|||||||
import se.su.dsv.scipro.system.ProjectType;
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class MailFacade implements Serializable {
|
public class MailFacade implements Serializable {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ProjectService projectService;
|
private ProjectService projectService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private IdeaService ideaService;
|
private IdeaService ideaService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private GeneralSystemSettingsService generalSystemSettingsService;
|
private GeneralSystemSettingsService generalSystemSettingsService;
|
||||||
|
|
||||||
private Set<Recipient> addProjectAuthors(ProjectStatus ps, Set<ProjectType> pc, Date startDate, Date endDate) {
|
private Set<Recipient> addProjectAuthors(
|
||||||
|
ProjectStatus ps,
|
||||||
|
Set<ProjectType> pc,
|
||||||
|
Date startDate,
|
||||||
|
Date endDate
|
||||||
|
) {
|
||||||
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
|
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
|
||||||
return authorsFromProjects(filter);
|
return authorsFromProjects(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Recipient> addProjectSupervisors(ProjectStatus ps, Set<ProjectType> pc, Date startDate, Date endDate) {
|
private Set<Recipient> addProjectSupervisors(
|
||||||
|
ProjectStatus ps,
|
||||||
|
Set<ProjectType> pc,
|
||||||
|
Date startDate,
|
||||||
|
Date endDate
|
||||||
|
) {
|
||||||
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
|
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
|
||||||
return supervisorsFromProjects(filter);
|
return supervisorsFromProjects(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Recipient> addProjectCoSupervisors(ProjectStatus ps, Set<ProjectType> pc, Date startDate, Date endDate) {
|
private Set<Recipient> addProjectCoSupervisors(
|
||||||
|
ProjectStatus ps,
|
||||||
|
Set<ProjectType> pc,
|
||||||
|
Date startDate,
|
||||||
|
Date endDate
|
||||||
|
) {
|
||||||
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
|
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
|
||||||
return coSupervisorsFromProjects(filter);
|
return coSupervisorsFromProjects(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Recipient> addProjectReviewers(ProjectStatus ps, Set<ProjectType> pc, Date startDate, Date endDate) {
|
private Set<Recipient> addProjectReviewers(
|
||||||
|
ProjectStatus ps,
|
||||||
|
Set<ProjectType> pc,
|
||||||
|
Date startDate,
|
||||||
|
Date endDate
|
||||||
|
) {
|
||||||
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
|
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
|
||||||
return reviewersFromProjects(filter);
|
return reviewersFromProjects(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProjectService.Filter setProjectParams(ProjectStatus status, Set<ProjectType> pc, Date startDate, Date endDate) {
|
private ProjectService.Filter setProjectParams(
|
||||||
|
ProjectStatus status,
|
||||||
|
Set<ProjectType> pc,
|
||||||
|
Date startDate,
|
||||||
|
Date endDate
|
||||||
|
) {
|
||||||
final ProjectService.Filter projectParams = new ProjectService.Filter();
|
final ProjectService.Filter projectParams = new ProjectService.Filter();
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
projectParams.setStatuses(new HashSet<>(Collections.singletonList(status)));
|
projectParams.setStatuses(new HashSet<>(Collections.singletonList(status)));
|
||||||
@ -91,7 +117,7 @@ public class MailFacade implements Serializable {
|
|||||||
List<Project> listOfProjects = projectService.findAll(filter);
|
List<Project> listOfProjects = projectService.findAll(filter);
|
||||||
Set<Recipient> recipients = new HashSet<>();
|
Set<Recipient> recipients = new HashSet<>();
|
||||||
for (Project p : listOfProjects) {
|
for (Project p : listOfProjects) {
|
||||||
for (User user : p.getCoSupervisors()){
|
for (User user : p.getCoSupervisors()) {
|
||||||
recipients.add(new UserRecipient(user));
|
recipients.add(new UserRecipient(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +129,7 @@ public class MailFacade implements Serializable {
|
|||||||
List<Project> listOProjects = projectService.findAll(filter);
|
List<Project> listOProjects = projectService.findAll(filter);
|
||||||
Set<Recipient> recipients = new HashSet<>();
|
Set<Recipient> recipients = new HashSet<>();
|
||||||
for (Project p : listOProjects) {
|
for (Project p : listOProjects) {
|
||||||
for (User user : p.getReviewers()){
|
for (User user : p.getReviewers()) {
|
||||||
recipients.add(new UserRecipient(user));
|
recipients.add(new UserRecipient(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,16 +138,22 @@ public class MailFacade implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<Recipient> addThesisSupport() {
|
private Set<Recipient> addThesisSupport() {
|
||||||
String thesisSupportMail = generalSystemSettingsService.getGeneralSystemSettingsInstance().getThesisSupportMail();
|
String thesisSupportMail = generalSystemSettingsService
|
||||||
|
.getGeneralSystemSettingsInstance()
|
||||||
|
.getThesisSupportMail();
|
||||||
if (thesisSupportMail != null) {
|
if (thesisSupportMail != null) {
|
||||||
return Collections.singleton(new EmailRecipient(thesisSupportMail));
|
return Collections.singleton(new EmailRecipient(thesisSupportMail));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Recipient> getRecipients(MailChoice choice, Set<ProjectType> pc, Date startDate, Date endDate) {
|
public Set<Recipient> getRecipients(
|
||||||
|
MailChoice choice,
|
||||||
|
Set<ProjectType> pc,
|
||||||
|
Date startDate,
|
||||||
|
Date endDate
|
||||||
|
) {
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case THESIS_SUPPORT:
|
case THESIS_SUPPORT:
|
||||||
return addThesisSupport();
|
return addThesisSupport();
|
||||||
@ -135,28 +167,64 @@ public class MailFacade implements Serializable {
|
|||||||
return addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
return addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
||||||
case ALL_FOLLOWERS:
|
case ALL_FOLLOWERS:
|
||||||
Set<Recipient> allFollowers = new HashSet<>();
|
Set<Recipient> allFollowers = new HashSet<>();
|
||||||
allFollowers.addAll(addProjectSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate));
|
allFollowers.addAll(
|
||||||
allFollowers.addAll(addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate));
|
addProjectSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate)
|
||||||
allFollowers.addAll(addProjectCoSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate));
|
);
|
||||||
|
allFollowers.addAll(
|
||||||
|
addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate)
|
||||||
|
);
|
||||||
|
allFollowers.addAll(
|
||||||
|
addProjectCoSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate)
|
||||||
|
);
|
||||||
return allFollowers;
|
return allFollowers;
|
||||||
case AUTHORS_MATCHED_IDEA:
|
case AUTHORS_MATCHED_IDEA:
|
||||||
IdeaService.Filter matchedFilter = setIdeaParams(Arrays.asList(Idea.Status.COMPLETED, Idea.Status.MATCHED), pc, startDate, endDate, null);
|
IdeaService.Filter matchedFilter = setIdeaParams(
|
||||||
|
Arrays.asList(Idea.Status.COMPLETED, Idea.Status.MATCHED),
|
||||||
|
pc,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
null
|
||||||
|
);
|
||||||
return authorsFromIdeas(matchedFilter);
|
return authorsFromIdeas(matchedFilter);
|
||||||
case AUTHORS_SUBMITTED_IDEA:
|
case AUTHORS_SUBMITTED_IDEA:
|
||||||
IdeaService.Filter submittedFilter = setIdeaParams(null, pc, startDate, endDate, Collections.singletonList(Type.STUDENT));
|
IdeaService.Filter submittedFilter = setIdeaParams(
|
||||||
|
null,
|
||||||
|
pc,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
Collections.singletonList(Type.STUDENT)
|
||||||
|
);
|
||||||
return authorsFromIdeas(submittedFilter);
|
return authorsFromIdeas(submittedFilter);
|
||||||
case SUPERVISORS_MATCHED_IDEA:
|
case SUPERVISORS_MATCHED_IDEA:
|
||||||
IdeaService.Filter supervisorMatchedFilter = setIdeaParams(Arrays.asList(Idea.Status.COMPLETED, Idea.Status.MATCHED), pc, startDate, endDate, null);
|
IdeaService.Filter supervisorMatchedFilter = setIdeaParams(
|
||||||
|
Arrays.asList(Idea.Status.COMPLETED, Idea.Status.MATCHED),
|
||||||
|
pc,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
null
|
||||||
|
);
|
||||||
return supervisorsFromIdeas(supervisorMatchedFilter);
|
return supervisorsFromIdeas(supervisorMatchedFilter);
|
||||||
case SUPERVISORS_SUBMITTED_IDEA:
|
case SUPERVISORS_SUBMITTED_IDEA:
|
||||||
IdeaService.Filter supervisorSubmittedFilter = setIdeaParams(null, pc, startDate, endDate, Collections.singletonList(Type.SUPERVISOR));
|
IdeaService.Filter supervisorSubmittedFilter = setIdeaParams(
|
||||||
|
null,
|
||||||
|
pc,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
Collections.singletonList(Type.SUPERVISOR)
|
||||||
|
);
|
||||||
return supervisorsFromIdeas(supervisorSubmittedFilter);
|
return supervisorsFromIdeas(supervisorSubmittedFilter);
|
||||||
default:
|
default:
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IdeaService.Filter setIdeaParams(Collection<Idea.Status> statuses, Set<ProjectType> pc, Date startDate, Date endDate, Collection<Type> types) {
|
private IdeaService.Filter setIdeaParams(
|
||||||
|
Collection<Idea.Status> statuses,
|
||||||
|
Set<ProjectType> pc,
|
||||||
|
Date startDate,
|
||||||
|
Date endDate,
|
||||||
|
Collection<Type> types
|
||||||
|
) {
|
||||||
final IdeaService.Filter ideaParams = new IdeaService.Filter();
|
final IdeaService.Filter ideaParams = new IdeaService.Filter();
|
||||||
if (statuses != null && !statuses.isEmpty()) {
|
if (statuses != null && !statuses.isEmpty()) {
|
||||||
ideaParams.setStatuses(statuses);
|
ideaParams.setStatuses(statuses);
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package se.su.dsv.scipro.date;
|
package se.su.dsv.scipro.date;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import se.su.dsv.scipro.data.enums.DateStyle;
|
import se.su.dsv.scipro.data.enums.DateStyle;
|
||||||
|
|
||||||
import java.util.Date;
|
public interface DateService {
|
||||||
|
|
||||||
public interface DateService {
|
|
||||||
String format(Date date);
|
String format(Date date);
|
||||||
String format(Date date, DateStyle style);
|
String format(Date date, DateStyle style);
|
||||||
String getFormat(DateStyle style);
|
String getFormat(DateStyle style);
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
package se.su.dsv.scipro.date;
|
package se.su.dsv.scipro.date;
|
||||||
|
|
||||||
|
|
||||||
import se.su.dsv.scipro.data.enums.DateStyle;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import se.su.dsv.scipro.data.enums.DateStyle;
|
||||||
|
|
||||||
public class DateServiceImpl implements DateService {
|
public class DateServiceImpl implements DateService {
|
||||||
|
|
||||||
|
private String findStyle(DateStyle style) {
|
||||||
private String findStyle(DateStyle style){
|
|
||||||
return style.getFormat();
|
return style.getFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -13,6 +8,10 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.NoSuchFileException;
|
import java.nio.file.NoSuchFileException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata about a specific file. To get access to the underlying data you need a
|
* Metadata about a specific file. To get access to the underlying data you need a
|
||||||
@ -138,8 +137,7 @@ public class FileDescription extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof FileDescription)) return false;
|
if (!(o instanceof FileDescription)) return false;
|
||||||
final FileDescription other = (FileDescription) o;
|
final FileDescription other = (FileDescription) o;
|
||||||
return other.canEqual(this)
|
return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
|
||||||
&& Objects.equals(this.getId(), other.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -173,7 +171,9 @@ public class FileDescription extends DomainObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getSubdirectory() {
|
private String getSubdirectory() {
|
||||||
return Long.toString((id / FILES_PER_SUBDIRECTORY) * FILES_PER_SUBDIRECTORY + FILES_PER_SUBDIRECTORY);
|
return Long.toString(
|
||||||
|
(id / FILES_PER_SUBDIRECTORY) * FILES_PER_SUBDIRECTORY + FILES_PER_SUBDIRECTORY
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDataAvailable() {
|
public boolean isDataAvailable() {
|
||||||
|
@ -4,7 +4,6 @@ import jakarta.transaction.Transactional;
|
|||||||
import se.su.dsv.scipro.system.JpaRepository;
|
import se.su.dsv.scipro.system.JpaRepository;
|
||||||
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public interface FileDescriptionRepo extends JpaRepository<FileDescription, Long>, QueryDslPredicateExecutor<FileDescription> {
|
public interface FileDescriptionRepo
|
||||||
}
|
extends JpaRepository<FileDescription, Long>, QueryDslPredicateExecutor<FileDescription> {}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.GenericRepo;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import se.su.dsv.scipro.system.GenericRepo;
|
||||||
|
|
||||||
|
public class FileDescriptionRepoImpl
|
||||||
|
extends GenericRepo<FileDescription, Long>
|
||||||
|
implements FileDescriptionRepo {
|
||||||
|
|
||||||
public class FileDescriptionRepoImpl extends GenericRepo<FileDescription, Long> implements FileDescriptionRepo {
|
|
||||||
@Inject
|
@Inject
|
||||||
public FileDescriptionRepoImpl(Provider<EntityManager> em) {
|
public FileDescriptionRepoImpl(Provider<EntityManager> em) {
|
||||||
super(em, FileDescription.class, QFileDescription.fileDescription);
|
super(em, FileDescription.class, QFileDescription.fileDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import java.util.Objects;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "file_reference")
|
@Table(name = "file_reference")
|
||||||
public class FileReference implements Serializable {
|
public class FileReference implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
@ -57,7 +58,7 @@ public class FileReference implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final FileReference that = (FileReference) o;
|
final FileReference that = (FileReference) o;
|
||||||
return Objects.equals(id, that.id) && fileDescription.equals(that.fileDescription);
|
return (Objects.equals(id, that.id) && fileDescription.equals(that.fileDescription));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -67,10 +68,7 @@ public class FileReference implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FileReference{" +
|
return ("FileReference{" + "id=" + id + ", fileDescription=" + fileDescription + '}');
|
||||||
"id=" + id +
|
|
||||||
", fileDescription=" + fileDescription +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import se.su.dsv.scipro.system.AbstractRepository;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import se.su.dsv.scipro.system.AbstractRepository;
|
||||||
|
|
||||||
public class FileReferenceRepositoryImpl extends AbstractRepository implements FileReferenceRepository {
|
public class FileReferenceRepositoryImpl
|
||||||
|
extends AbstractRepository
|
||||||
|
implements FileReferenceRepository {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FileReferenceRepositoryImpl(final Provider<EntityManager> em) {
|
public FileReferenceRepositoryImpl(final Provider<EntityManager> em) {
|
||||||
@ -30,8 +31,8 @@ public class FileReferenceRepositoryImpl extends AbstractRepository implements F
|
|||||||
@Override
|
@Override
|
||||||
public long countReferencesTo(final FileDescription fileDescription) {
|
public long countReferencesTo(final FileDescription fileDescription) {
|
||||||
return from(QFileReference.fileReference)
|
return from(QFileReference.fileReference)
|
||||||
.select(QFileReference.fileReference.count())
|
.select(QFileReference.fileReference.count())
|
||||||
.where(QFileReference.fileReference.fileDescription.eq(fileDescription))
|
.where(QFileReference.fileReference.fileDescription.eq(fileDescription))
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.GenericService;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import se.su.dsv.scipro.system.GenericService;
|
||||||
|
|
||||||
public interface FileService extends GenericService<FileDescription, Long> {
|
public interface FileService extends GenericService<FileDescription, Long> {
|
||||||
FileReference storeFile(FileUpload fileUpload);
|
FileReference storeFile(FileUpload fileUpload);
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
|
||||||
public class FileServiceImpl extends AbstractServiceImpl<FileDescription, Long> implements FileService {
|
public class FileServiceImpl
|
||||||
|
extends AbstractServiceImpl<FileDescription, Long>
|
||||||
|
implements FileService {
|
||||||
|
|
||||||
private final FileReferenceRepository fileReferenceRepository;
|
private final FileReferenceRepository fileReferenceRepository;
|
||||||
private final FileDescriptionRepo fileDescriptionRepository;
|
private final FileDescriptionRepo fileDescriptionRepository;
|
||||||
@ -16,11 +17,11 @@ public class FileServiceImpl extends AbstractServiceImpl<FileDescription, Long>
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FileServiceImpl(
|
public FileServiceImpl(
|
||||||
Provider<EntityManager> em,
|
Provider<EntityManager> em,
|
||||||
final FileReferenceRepository fileReferenceRepository,
|
final FileReferenceRepository fileReferenceRepository,
|
||||||
final FileDescriptionRepo fileDescriptionRepository,
|
final FileDescriptionRepo fileDescriptionRepository,
|
||||||
final FileStore fileStore)
|
final FileStore fileStore
|
||||||
{
|
) {
|
||||||
super(em, FileDescription.class, QFileDescription.fileDescription);
|
super(em, FileDescription.class, QFileDescription.fileDescription);
|
||||||
this.fileReferenceRepository = fileReferenceRepository;
|
this.fileReferenceRepository = fileReferenceRepository;
|
||||||
this.fileDescriptionRepository = fileDescriptionRepository;
|
this.fileDescriptionRepository = fileDescriptionRepository;
|
||||||
@ -80,5 +81,4 @@ public class FileServiceImpl extends AbstractServiceImpl<FileDescription, Long>
|
|||||||
fileStore.deleteData(fileDescription);
|
fileStore.deleteData(fileDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
public enum FileSource {
|
public enum FileSource {
|
||||||
FILES,
|
FILES,
|
||||||
FORUM,
|
FORUM,
|
||||||
FINAL_THESIS,
|
FINAL_THESIS,
|
||||||
PEER_REVIEW,
|
PEER_REVIEW,
|
||||||
PEER_REQUEST,
|
PEER_REQUEST,
|
||||||
FINAL_SEMINAR,
|
FINAL_SEMINAR,
|
||||||
ACTIVITY_PLAN
|
ACTIVITY_PLAN,
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
public interface FileUpload {
|
public interface FileUpload {
|
||||||
String getFileName();
|
String getFileName();
|
||||||
|
@ -12,11 +12,10 @@ import jakarta.persistence.JoinColumn;
|
|||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToOne;
|
import jakarta.persistence.OneToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import java.util.Objects;
|
||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "project_file")
|
@Table(name = "project_file")
|
||||||
public class ProjectFile extends DomainObject {
|
public class ProjectFile extends DomainObject {
|
||||||
@ -88,22 +87,39 @@ public class ProjectFile extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof ProjectFile)) return false;
|
if (!(o instanceof ProjectFile)) return false;
|
||||||
final ProjectFile other = (ProjectFile) o;
|
final ProjectFile other = (ProjectFile) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& super.equals(o)
|
other.canEqual(this) &&
|
||||||
&& Objects.equals(this.getId(), other.getId())
|
super.equals(o) &&
|
||||||
&& Objects.equals(this.getProject(), other.getProject())
|
Objects.equals(this.getId(), other.getId()) &&
|
||||||
&& Objects.equals(this.getFileSource(), other.getFileSource())
|
Objects.equals(this.getProject(), other.getProject()) &&
|
||||||
&& Objects.equals(this.getFileDescription(), other.getFileDescription());
|
Objects.equals(this.getFileSource(), other.getFileSource()) &&
|
||||||
|
Objects.equals(this.getFileDescription(), other.getFileDescription())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(this.getId(), this.getProject(), this.getFileSource(), this.getFileDescription());
|
return Objects.hash(
|
||||||
|
this.getId(),
|
||||||
|
this.getProject(),
|
||||||
|
this.getFileSource(),
|
||||||
|
this.getFileDescription()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ProjectFile(id=" + this.getId() + ", project=" + this.getProject() + ", fileSource=" + this.getFileSource() + ", fileDescription=" + this.getFileDescription() + ")";
|
return (
|
||||||
|
"ProjectFile(id=" +
|
||||||
|
this.getId() +
|
||||||
|
", project=" +
|
||||||
|
this.getProject() +
|
||||||
|
", fileSource=" +
|
||||||
|
this.getFileSource() +
|
||||||
|
", fileDescription=" +
|
||||||
|
this.getFileDescription() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
|
||||||
import se.su.dsv.scipro.system.JpaRepository;
|
|
||||||
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.JpaRepository;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
|
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
||||||
|
|
||||||
public interface ProjectFileRepository extends JpaRepository<ProjectFile, Long>, QueryDslPredicateExecutor<ProjectFile> {
|
public interface ProjectFileRepository
|
||||||
|
extends JpaRepository<ProjectFile, Long>, QueryDslPredicateExecutor<ProjectFile> {
|
||||||
List<ProjectFile> latestUpload(Project project, int amount);
|
List<ProjectFile> latestUpload(Project project, int amount);
|
||||||
|
|
||||||
Collection<ProjectFile> getProjectFiles(Project project, Pageable pageable);
|
Collection<ProjectFile> getProjectFiles(Project project, Pageable pageable);
|
||||||
|
@ -2,16 +2,18 @@ package se.su.dsv.scipro.file;
|
|||||||
|
|
||||||
import com.querydsl.core.types.dsl.Expressions;
|
import com.querydsl.core.types.dsl.Expressions;
|
||||||
import com.querydsl.jpa.impl.JPAQuery;
|
import com.querydsl.jpa.impl.JPAQuery;
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
|
|
||||||
|
public class ProjectFileRepositoryImpl
|
||||||
|
extends AbstractServiceImpl<ProjectFile, Long>
|
||||||
|
implements ProjectFileRepository {
|
||||||
|
|
||||||
public class ProjectFileRepositoryImpl extends AbstractServiceImpl<ProjectFile, Long> implements ProjectFileRepository {
|
|
||||||
@Inject
|
@Inject
|
||||||
public ProjectFileRepositoryImpl(final Provider<EntityManager> em) {
|
public ProjectFileRepositoryImpl(final Provider<EntityManager> em) {
|
||||||
super(em, ProjectFile.class, QProjectFile.projectFile);
|
super(em, ProjectFile.class, QProjectFile.projectFile);
|
||||||
@ -20,10 +22,10 @@ public class ProjectFileRepositoryImpl extends AbstractServiceImpl<ProjectFile,
|
|||||||
@Override
|
@Override
|
||||||
public List<ProjectFile> latestUpload(final Project project, final int amount) {
|
public List<ProjectFile> latestUpload(final Project project, final int amount) {
|
||||||
return new JPAQuery<ProjectFile>(em())
|
return new JPAQuery<ProjectFile>(em())
|
||||||
.from(QProjectFile.projectFile)
|
.from(QProjectFile.projectFile)
|
||||||
.where(QProjectFile.projectFile.project.eq(project))
|
.where(QProjectFile.projectFile.project.eq(project))
|
||||||
.limit(amount)
|
.limit(amount)
|
||||||
.fetch();
|
.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,9 +39,17 @@ public class ProjectFileRepositoryImpl extends AbstractServiceImpl<ProjectFile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ProjectFile> findProjectFile(final FileDescription fileDescription, final Project project) {
|
public Optional<ProjectFile> findProjectFile(
|
||||||
return Optional.ofNullable(findOne(Expressions.allOf(
|
final FileDescription fileDescription,
|
||||||
QProjectFile.projectFile.fileReference.fileDescription.eq(fileDescription),
|
final Project project
|
||||||
QProjectFile.projectFile.project.eq(project))));
|
) {
|
||||||
|
return Optional.ofNullable(
|
||||||
|
findOne(
|
||||||
|
Expressions.allOf(
|
||||||
|
QProjectFile.projectFile.fileReference.fileDescription.eq(fileDescription),
|
||||||
|
QProjectFile.projectFile.project.eq(project)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
|
|
||||||
public interface ProjectFileService {
|
public interface ProjectFileService {
|
||||||
ProjectFile store(ProjectFileUpload projectFileUpload, final FileSource fileSource);
|
ProjectFile store(ProjectFileUpload projectFileUpload, final FileSource fileSource);
|
||||||
|
@ -1,37 +1,46 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
|
|
||||||
public class ProjectFileServiceImpl implements ProjectFileService {
|
public class ProjectFileServiceImpl implements ProjectFileService {
|
||||||
|
|
||||||
private final FileService fileService;
|
private final FileService fileService;
|
||||||
private final ProjectFileRepository projectFileRepository;
|
private final ProjectFileRepository projectFileRepository;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ProjectFileServiceImpl(
|
public ProjectFileServiceImpl(
|
||||||
final FileService fileService,
|
final FileService fileService,
|
||||||
final ProjectFileRepository projectFileRepository)
|
final ProjectFileRepository projectFileRepository
|
||||||
{
|
) {
|
||||||
this.fileService = fileService;
|
this.fileService = fileService;
|
||||||
this.projectFileRepository = projectFileRepository;
|
this.projectFileRepository = projectFileRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ProjectFile store(final ProjectFileUpload projectFileUpload, final FileSource fileSource) {
|
public ProjectFile store(
|
||||||
|
final ProjectFileUpload projectFileUpload,
|
||||||
|
final FileSource fileSource
|
||||||
|
) {
|
||||||
final FileReference fileDescription = fileService.storeFile(projectFileUpload);
|
final FileReference fileDescription = fileService.storeFile(projectFileUpload);
|
||||||
return createProjectFile(fileDescription, projectFileUpload.getProject(), fileSource);
|
return createProjectFile(fileDescription, projectFileUpload.getProject(), fileSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ProjectFile promote(final FileDescription fileDescription, final Project project, final FileSource fileSource) {
|
public ProjectFile promote(
|
||||||
Optional<ProjectFile> existing = projectFileRepository.findProjectFile(fileDescription, project);
|
final FileDescription fileDescription,
|
||||||
|
final Project project,
|
||||||
|
final FileSource fileSource
|
||||||
|
) {
|
||||||
|
Optional<ProjectFile> existing = projectFileRepository.findProjectFile(
|
||||||
|
fileDescription,
|
||||||
|
project
|
||||||
|
);
|
||||||
if (existing.isPresent()) {
|
if (existing.isPresent()) {
|
||||||
return existing.get();
|
return existing.get();
|
||||||
}
|
}
|
||||||
@ -39,7 +48,11 @@ public class ProjectFileServiceImpl implements ProjectFileService {
|
|||||||
return createProjectFile(reference, project, fileSource);
|
return createProjectFile(reference, project, fileSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProjectFile createProjectFile(FileReference reference, Project project, FileSource fileSource) {
|
private ProjectFile createProjectFile(
|
||||||
|
FileReference reference,
|
||||||
|
Project project,
|
||||||
|
FileSource fileSource
|
||||||
|
) {
|
||||||
final ProjectFile projectFile = new ProjectFile();
|
final ProjectFile projectFile = new ProjectFile();
|
||||||
projectFile.setFileReference(reference);
|
projectFile.setFileReference(reference);
|
||||||
projectFile.setFileSource(fileSource);
|
projectFile.setFileSource(fileSource);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package se.su.dsv.scipro.file;
|
package se.su.dsv.scipro.file;
|
||||||
|
|
||||||
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
|
||||||
public interface ProjectFileUpload extends FileUpload {
|
public interface ProjectFileUpload extends FileUpload {
|
||||||
|
@ -4,6 +4,7 @@ import se.su.dsv.scipro.project.Project;
|
|||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
class AbstractOppositionEvent {
|
class AbstractOppositionEvent {
|
||||||
|
|
||||||
private final FinalSeminarOpposition opposition;
|
private final FinalSeminarOpposition opposition;
|
||||||
|
|
||||||
protected AbstractOppositionEvent(FinalSeminarOpposition opposition) {
|
protected AbstractOppositionEvent(FinalSeminarOpposition opposition) {
|
||||||
|
@ -4,6 +4,7 @@ import se.su.dsv.scipro.project.Project;
|
|||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
class AbstractParticipationEvent {
|
class AbstractParticipationEvent {
|
||||||
|
|
||||||
private final FinalSeminarActiveParticipation participation;
|
private final FinalSeminarActiveParticipation participation;
|
||||||
|
|
||||||
protected AbstractParticipationEvent(FinalSeminarActiveParticipation participation) {
|
protected AbstractParticipationEvent(FinalSeminarActiveParticipation participation) {
|
||||||
|
@ -4,6 +4,7 @@ import se.su.dsv.scipro.project.Project;
|
|||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
class AbstractRespondentEvent {
|
class AbstractRespondentEvent {
|
||||||
|
|
||||||
private final FinalSeminarRespondent respondent;
|
private final FinalSeminarRespondent respondent;
|
||||||
|
|
||||||
protected AbstractRespondentEvent(FinalSeminarRespondent respondent) {
|
protected AbstractRespondentEvent(FinalSeminarRespondent respondent) {
|
||||||
|
@ -3,74 +3,84 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public abstract class ActiveParticipationRegistrationErrorStatus {
|
public abstract class ActiveParticipationRegistrationErrorStatus {
|
||||||
ActiveParticipationRegistrationErrorStatus() {
|
|
||||||
}
|
ActiveParticipationRegistrationErrorStatus() {}
|
||||||
|
|
||||||
public abstract <A> A fold(
|
public abstract <A> A fold(
|
||||||
Function<TooManyParticipants, A> a,
|
Function<TooManyParticipants, A> a,
|
||||||
Function<ManualParticipants, A> b,
|
Function<ManualParticipants, A> b,
|
||||||
Function<ParticipationAlreadyParticipating, A> e,
|
Function<ParticipationAlreadyParticipating, A> e,
|
||||||
Function<ParticipationAlreadyHappened, A> f,
|
Function<ParticipationAlreadyHappened, A> f,
|
||||||
Function<ParticipationFinalSeminarCancelled, A> g);
|
Function<ParticipationFinalSeminarCancelled, A> g
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final class TooManyParticipants extends ActiveParticipationRegistrationErrorStatus {
|
final class TooManyParticipants extends ActiveParticipationRegistrationErrorStatus {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <A> A fold(
|
public <A> A fold(
|
||||||
Function<TooManyParticipants, A> a,
|
Function<TooManyParticipants, A> a,
|
||||||
Function<ManualParticipants, A> b,
|
Function<ManualParticipants, A> b,
|
||||||
Function<ParticipationAlreadyParticipating, A> e,
|
Function<ParticipationAlreadyParticipating, A> e,
|
||||||
Function<ParticipationAlreadyHappened, A> f,
|
Function<ParticipationAlreadyHappened, A> f,
|
||||||
Function<ParticipationFinalSeminarCancelled, A> g) {
|
Function<ParticipationFinalSeminarCancelled, A> g
|
||||||
|
) {
|
||||||
return a.apply(this);
|
return a.apply(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ManualParticipants extends ActiveParticipationRegistrationErrorStatus {
|
final class ManualParticipants extends ActiveParticipationRegistrationErrorStatus {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <A> A fold(
|
public <A> A fold(
|
||||||
Function<TooManyParticipants, A> a,
|
Function<TooManyParticipants, A> a,
|
||||||
Function<ManualParticipants, A> b,
|
Function<ManualParticipants, A> b,
|
||||||
Function<ParticipationAlreadyParticipating, A> e,
|
Function<ParticipationAlreadyParticipating, A> e,
|
||||||
Function<ParticipationAlreadyHappened, A> f,
|
Function<ParticipationAlreadyHappened, A> f,
|
||||||
Function<ParticipationFinalSeminarCancelled, A> g) {
|
Function<ParticipationFinalSeminarCancelled, A> g
|
||||||
|
) {
|
||||||
return b.apply(this);
|
return b.apply(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ParticipationAlreadyParticipating extends ActiveParticipationRegistrationErrorStatus {
|
final class ParticipationAlreadyParticipating extends ActiveParticipationRegistrationErrorStatus {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <A> A fold(
|
public <A> A fold(
|
||||||
Function<TooManyParticipants, A> a,
|
Function<TooManyParticipants, A> a,
|
||||||
Function<ManualParticipants, A> b,
|
Function<ManualParticipants, A> b,
|
||||||
Function<ParticipationAlreadyParticipating, A> e,
|
Function<ParticipationAlreadyParticipating, A> e,
|
||||||
Function<ParticipationAlreadyHappened, A> f,
|
Function<ParticipationAlreadyHappened, A> f,
|
||||||
Function<ParticipationFinalSeminarCancelled, A> g) {
|
Function<ParticipationFinalSeminarCancelled, A> g
|
||||||
|
) {
|
||||||
return e.apply(this);
|
return e.apply(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ParticipationAlreadyHappened extends ActiveParticipationRegistrationErrorStatus {
|
final class ParticipationAlreadyHappened extends ActiveParticipationRegistrationErrorStatus {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <A> A fold(
|
public <A> A fold(
|
||||||
Function<TooManyParticipants, A> a,
|
Function<TooManyParticipants, A> a,
|
||||||
Function<ManualParticipants, A> b,
|
Function<ManualParticipants, A> b,
|
||||||
Function<ParticipationAlreadyParticipating, A> e,
|
Function<ParticipationAlreadyParticipating, A> e,
|
||||||
Function<ParticipationAlreadyHappened, A> f,
|
Function<ParticipationAlreadyHappened, A> f,
|
||||||
Function<ParticipationFinalSeminarCancelled, A> g) {
|
Function<ParticipationFinalSeminarCancelled, A> g
|
||||||
|
) {
|
||||||
return f.apply(this);
|
return f.apply(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ParticipationFinalSeminarCancelled extends ActiveParticipationRegistrationErrorStatus {
|
final class ParticipationFinalSeminarCancelled extends ActiveParticipationRegistrationErrorStatus {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <A> A fold(
|
public <A> A fold(
|
||||||
Function<TooManyParticipants, A> a,
|
Function<TooManyParticipants, A> a,
|
||||||
Function<ManualParticipants, A> b,
|
Function<ManualParticipants, A> b,
|
||||||
Function<ParticipationAlreadyParticipating, A> e,
|
Function<ParticipationAlreadyParticipating, A> e,
|
||||||
Function<ParticipationAlreadyHappened, A> f,
|
Function<ParticipationAlreadyHappened, A> f,
|
||||||
Function<ParticipationFinalSeminarCancelled, A> g) {
|
Function<ParticipationFinalSeminarCancelled, A> g
|
||||||
|
) {
|
||||||
return g.apply(this);
|
return g.apply(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import se.su.dsv.scipro.project.Author;
|
import se.su.dsv.scipro.project.Author;
|
||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public interface AuthorRepository {
|
public interface AuthorRepository {
|
||||||
Optional<Author> findByProjectAndUser(Project project, User user);
|
Optional<Author> findByProjectAndUser(Project project, User user);
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import jakarta.inject.Provider;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import se.su.dsv.scipro.project.Author;
|
import se.su.dsv.scipro.project.Author;
|
||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
import se.su.dsv.scipro.project.ProjectStatus;
|
import se.su.dsv.scipro.project.ProjectStatus;
|
||||||
@ -8,13 +13,8 @@ import se.su.dsv.scipro.system.AbstractRepository;
|
|||||||
import se.su.dsv.scipro.system.ProjectType;
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
|
||||||
import jakarta.inject.Provider;
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class AuthorRepositoryImpl extends AbstractRepository implements AuthorRepository {
|
public class AuthorRepositoryImpl extends AbstractRepository implements AuthorRepository {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AuthorRepositoryImpl(Provider<EntityManager> em) {
|
public AuthorRepositoryImpl(Provider<EntityManager> em) {
|
||||||
super(em);
|
super(em);
|
||||||
@ -24,10 +24,8 @@ public class AuthorRepositoryImpl extends AbstractRepository implements AuthorRe
|
|||||||
public Optional<Author> findByProjectAndUser(Project project, User user) {
|
public Optional<Author> findByProjectAndUser(Project project, User user) {
|
||||||
final QAuthor author = QAuthor.author;
|
final QAuthor author = QAuthor.author;
|
||||||
final Author author1 = from(author)
|
final Author author1 = from(author)
|
||||||
.where(
|
.where(author.project.eq(project), author.user.eq(user))
|
||||||
author.project.eq(project),
|
.fetchOne();
|
||||||
author.user.eq(user))
|
|
||||||
.fetchOne();
|
|
||||||
return Optional.ofNullable(author1);
|
return Optional.ofNullable(author1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,9 +33,11 @@ public class AuthorRepositoryImpl extends AbstractRepository implements AuthorRe
|
|||||||
public List<Author> getSubscribersWithActiveProjectOnType(ProjectType projectType) {
|
public List<Author> getSubscribersWithActiveProjectOnType(ProjectType projectType) {
|
||||||
final QAuthor author = QAuthor.author;
|
final QAuthor author = QAuthor.author;
|
||||||
return from(author)
|
return from(author)
|
||||||
.where(author.subscribedToFinalSeminarNotifications.isTrue(),
|
.where(
|
||||||
author.project.projectType.eq(projectType),
|
author.subscribedToFinalSeminarNotifications.isTrue(),
|
||||||
author.project.projectStatus.eq(ProjectStatus.ACTIVE))
|
author.project.projectType.eq(projectType),
|
||||||
.fetch();
|
author.project.projectStatus.eq(ProjectStatus.ACTIVE)
|
||||||
|
)
|
||||||
|
.fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,6 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryInit;
|
import com.querydsl.core.annotations.QueryInit;
|
||||||
import jakarta.persistence.GenerationType;
|
|
||||||
import se.su.dsv.scipro.data.dataobjects.Member;
|
|
||||||
import se.su.dsv.scipro.file.FileReference;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.system.Language;
|
|
||||||
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
|
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
import jakarta.persistence.Basic;
|
||||||
import jakarta.persistence.Cacheable;
|
import jakarta.persistence.Cacheable;
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
@ -18,12 +9,12 @@ import jakarta.persistence.Entity;
|
|||||||
import jakarta.persistence.EnumType;
|
import jakarta.persistence.EnumType;
|
||||||
import jakarta.persistence.Enumerated;
|
import jakarta.persistence.Enumerated;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.OneToOne;
|
import jakarta.persistence.OneToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -32,11 +23,19 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import se.su.dsv.scipro.data.dataobjects.Member;
|
||||||
|
import se.su.dsv.scipro.file.FileReference;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.Language;
|
||||||
|
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
|
||||||
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "final_seminar")
|
@Table(name = "final_seminar")
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
public class FinalSeminar extends LazyDeletableDomainObject {
|
public class FinalSeminar extends LazyDeletableDomainObject {
|
||||||
|
|
||||||
public static final String U_SINGULAR = "Final seminar";
|
public static final String U_SINGULAR = "Final seminar";
|
||||||
|
|
||||||
public static final int DEFAULT_MAX_OPPONENTS = 2;
|
public static final int DEFAULT_MAX_OPPONENTS = 2;
|
||||||
@ -100,7 +99,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
|||||||
|
|
||||||
@OneToOne(optional = false)
|
@OneToOne(optional = false)
|
||||||
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
||||||
@QueryInit({"projectType", "headSupervisor"})
|
@QueryInit({ "projectType", "headSupervisor" })
|
||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
@ -118,8 +117,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
|||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// Constructors
|
// Constructors
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
public FinalSeminar() {
|
public FinalSeminar() {}
|
||||||
}
|
|
||||||
|
|
||||||
public FinalSeminar(int maxOpponents, int maxParticipants) {
|
public FinalSeminar(int maxOpponents, int maxParticipants) {
|
||||||
this.maxOpponents = maxOpponents;
|
this.maxOpponents = maxOpponents;
|
||||||
@ -243,7 +241,9 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
|||||||
return Collections.unmodifiableSet(activeParticipations);
|
return Collections.unmodifiableSet(activeParticipations);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveParticipations(Collection<FinalSeminarActiveParticipation> activeParticipations) {
|
public void setActiveParticipations(
|
||||||
|
Collection<FinalSeminarActiveParticipation> activeParticipations
|
||||||
|
) {
|
||||||
this.activeParticipations.clear();
|
this.activeParticipations.clear();
|
||||||
this.activeParticipations.addAll(activeParticipations);
|
this.activeParticipations.addAll(activeParticipations);
|
||||||
}
|
}
|
||||||
@ -273,9 +273,9 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof FinalSeminar)) return false;
|
if (!(o instanceof FinalSeminar)) return false;
|
||||||
final FinalSeminar other = (FinalSeminar) o;
|
final FinalSeminar other = (FinalSeminar) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& super.equals(o)
|
other.canEqual(this) && super.equals(o) && Objects.equals(this.getId(), other.getId())
|
||||||
&& Objects.equals(this.getId(), other.getId());
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -285,14 +285,35 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FinalSeminar(id=" + this.getId() + ", project=" + this.getProject() + ", startDate=" +
|
return (
|
||||||
this.getStartDate() + ", room=" + this.getRoom() + ", activeParticipations=" +
|
"FinalSeminar(id=" +
|
||||||
this.getActiveParticipations() + ", oppositions=" + this.getOppositions() +
|
this.getId() +
|
||||||
", respondents=" + this.getRespondents() + ", document=" + this.getDocument() +
|
", project=" +
|
||||||
", documentUploadDate=" + this.getDocumentUploadDate() + ", presentationLanguage=" +
|
this.getProject() +
|
||||||
this.getPresentationLanguage() + ", maxOpponents=" + this.getMaxOpponents() +
|
", startDate=" +
|
||||||
", maxParticipants=" + this.getMaxParticipants() + ", creationReason=" +
|
this.getStartDate() +
|
||||||
this.getCreationReason() + ")";
|
", room=" +
|
||||||
|
this.getRoom() +
|
||||||
|
", activeParticipations=" +
|
||||||
|
this.getActiveParticipations() +
|
||||||
|
", oppositions=" +
|
||||||
|
this.getOppositions() +
|
||||||
|
", respondents=" +
|
||||||
|
this.getRespondents() +
|
||||||
|
", document=" +
|
||||||
|
this.getDocument() +
|
||||||
|
", documentUploadDate=" +
|
||||||
|
this.getDocumentUploadDate() +
|
||||||
|
", presentationLanguage=" +
|
||||||
|
this.getPresentationLanguage() +
|
||||||
|
", maxOpponents=" +
|
||||||
|
this.getMaxOpponents() +
|
||||||
|
", maxParticipants=" +
|
||||||
|
this.getMaxParticipants() +
|
||||||
|
", creationReason=" +
|
||||||
|
this.getCreationReason() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
@ -314,9 +335,9 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
|||||||
activeParticipations.removeIf(next -> next.getUser().equals(user));
|
activeParticipations.removeIf(next -> next.getUser().equals(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<User> getActiveParticipants(){
|
public Set<User> getActiveParticipants() {
|
||||||
Set<User> activeParticipants = new HashSet<>();
|
Set<User> activeParticipants = new HashSet<>();
|
||||||
for (FinalSeminarActiveParticipation fsap : activeParticipations){
|
for (FinalSeminarActiveParticipation fsap : activeParticipations) {
|
||||||
activeParticipants.add(fsap.getUser());
|
activeParticipants.add(fsap.getUser());
|
||||||
}
|
}
|
||||||
return activeParticipants;
|
return activeParticipants;
|
||||||
@ -334,9 +355,9 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
|||||||
this.oppositions.remove(opposition);
|
this.oppositions.remove(opposition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<User> getOpponents(){
|
public Set<User> getOpponents() {
|
||||||
Set<User> opponents = new HashSet<>();
|
Set<User> opponents = new HashSet<>();
|
||||||
for (FinalSeminarOpposition fso : oppositions){
|
for (FinalSeminarOpposition fso : oppositions) {
|
||||||
opponents.add(fso.getUser());
|
opponents.add(fso.getUser());
|
||||||
}
|
}
|
||||||
return opponents;
|
return opponents;
|
||||||
@ -350,10 +371,12 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
|||||||
return getNotGradedParticipations(respondents);
|
return getNotGradedParticipations(respondents);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<User> getNotGradedParticipations(Set<? extends FinalSeminarParticipation> participations) {
|
private Collection<User> getNotGradedParticipations(
|
||||||
|
Set<? extends FinalSeminarParticipation> participations
|
||||||
|
) {
|
||||||
List<User> result = new ArrayList<>();
|
List<User> result = new ArrayList<>();
|
||||||
for (FinalSeminarParticipation participation : participations) {
|
for (FinalSeminarParticipation participation : participations) {
|
||||||
if(participation.getGrade() == null) {
|
if (participation.getGrade() == null) {
|
||||||
result.add(participation.getUser());
|
result.add(participation.getUser());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import jakarta.persistence.JoinColumn;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
|
|
||||||
import jakarta.persistence.Cacheable;
|
import jakarta.persistence.Cacheable;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "final_seminar_active_participation")
|
@Table(name = "final_seminar_active_participation")
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
public class FinalSeminarActiveParticipation extends FinalSeminarParticipation {
|
public class FinalSeminarActiveParticipation extends FinalSeminarParticipation {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// JPA-mappings of foreign keys in this table (final_seminar_active_participation)
|
// JPA-mappings of foreign keys in this table (final_seminar_active_participation)
|
||||||
// referencing other tables.
|
// referencing other tables.
|
||||||
@ -40,9 +40,9 @@ public class FinalSeminarActiveParticipation extends FinalSeminarParticipation {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof FinalSeminarActiveParticipation)) return false;
|
if (!(o instanceof FinalSeminarActiveParticipation)) return false;
|
||||||
final FinalSeminarActiveParticipation other = (FinalSeminarActiveParticipation) o;
|
final FinalSeminarActiveParticipation other = (FinalSeminarActiveParticipation) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& super.equals(o)
|
other.canEqual(this) && super.equals(o) && Objects.equals(this.project, other.project)
|
||||||
&& Objects.equals(this.project, other.project);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public interface FinalSeminarActiveParticipationRepository {
|
public interface FinalSeminarActiveParticipationRepository {
|
||||||
List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel(User user, ProjectType projectType);
|
List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel(
|
||||||
|
User user,
|
||||||
|
ProjectType projectType
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,34 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.AbstractRepository;
|
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import se.su.dsv.scipro.system.AbstractRepository;
|
||||||
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
|
public class FinalSeminarActiveParticipationRepositoryImpl
|
||||||
|
extends AbstractRepository
|
||||||
|
implements FinalSeminarActiveParticipationRepository {
|
||||||
|
|
||||||
public class FinalSeminarActiveParticipationRepositoryImpl extends AbstractRepository implements FinalSeminarActiveParticipationRepository {
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarActiveParticipationRepositoryImpl(Provider<EntityManager> em) {
|
public FinalSeminarActiveParticipationRepositoryImpl(Provider<EntityManager> em) {
|
||||||
super(em);
|
super(em);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel(User user, ProjectType projectType) {
|
public List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel(
|
||||||
|
User user,
|
||||||
|
ProjectType projectType
|
||||||
|
) {
|
||||||
return from(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation)
|
return from(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation)
|
||||||
.where(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation.user.eq(user))
|
.where(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation.user.eq(user))
|
||||||
.where(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation.project.projectType.eq(projectType))
|
.where(
|
||||||
.fetch();
|
QFinalSeminarActiveParticipation.finalSeminarActiveParticipation.project.projectType.eq(
|
||||||
|
projectType
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
import se.su.dsv.scipro.system.GenericService;
|
import se.su.dsv.scipro.system.GenericService;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
public interface FinalSeminarActiveParticipationService extends GenericService<FinalSeminarActiveParticipation, Long>{
|
public interface FinalSeminarActiveParticipationService
|
||||||
|
extends GenericService<FinalSeminarActiveParticipation, Long> {
|
||||||
FinalSeminarActiveParticipation findByFinalSeminarUser(FinalSeminar finalSeminar,User user);
|
FinalSeminarActiveParticipation findByFinalSeminarUser(FinalSeminar finalSeminar, User user);
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,34 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
public class FinalSeminarActiveParticipationServiceImpl extends AbstractServiceImpl<FinalSeminarActiveParticipation, Long> implements FinalSeminarActiveParticipationService {
|
public class FinalSeminarActiveParticipationServiceImpl
|
||||||
|
extends AbstractServiceImpl<FinalSeminarActiveParticipation, Long>
|
||||||
|
implements FinalSeminarActiveParticipationService {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarActiveParticipationServiceImpl(Provider<EntityManager> em) {
|
public FinalSeminarActiveParticipationServiceImpl(Provider<EntityManager> em) {
|
||||||
super(em, FinalSeminarActiveParticipation.class, QFinalSeminarActiveParticipation.finalSeminarActiveParticipation);
|
super(
|
||||||
|
em,
|
||||||
|
FinalSeminarActiveParticipation.class,
|
||||||
|
QFinalSeminarActiveParticipation.finalSeminarActiveParticipation
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FinalSeminarActiveParticipation findByFinalSeminarUser(FinalSeminar finalSeminar,User user){
|
public FinalSeminarActiveParticipation findByFinalSeminarUser(
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
User user
|
||||||
|
) {
|
||||||
for (FinalSeminarActiveParticipation fsap : finalSeminar.getActiveParticipations()) {
|
for (FinalSeminarActiveParticipation fsap : finalSeminar.getActiveParticipations()) {
|
||||||
if(fsap.getUser().equals(user)){
|
if (fsap.getUser().equals(user)) {
|
||||||
return fsap;
|
return fsap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,18 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
|
||||||
public final class FinalSeminarCreatedEvent {
|
public final class FinalSeminarCreatedEvent {
|
||||||
private final FinalSeminar finalSeminar;
|
|
||||||
|
|
||||||
public FinalSeminar getFinalSeminar(){
|
private final FinalSeminar finalSeminar;
|
||||||
|
|
||||||
|
public FinalSeminar getFinalSeminar() {
|
||||||
return finalSeminar;
|
return finalSeminar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FinalSeminarCreatedEvent(FinalSeminar finalSeminar) {
|
public FinalSeminarCreatedEvent(FinalSeminar finalSeminar) {
|
||||||
this.finalSeminar = finalSeminar;
|
this.finalSeminar = finalSeminar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project getProject() {
|
public Project getProject() {
|
||||||
return finalSeminar.getProject();
|
return finalSeminar.getProject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,10 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import se.su.dsv.scipro.data.dataobjects.Member;
|
import se.su.dsv.scipro.data.dataobjects.Member;
|
||||||
import se.su.dsv.scipro.notifications.NotificationController;
|
import se.su.dsv.scipro.notifications.NotificationController;
|
||||||
import se.su.dsv.scipro.notifications.dataobject.NotificationSource;
|
import se.su.dsv.scipro.notifications.dataobject.NotificationSource;
|
||||||
@ -9,21 +13,17 @@ import se.su.dsv.scipro.notifications.dataobject.SeminarEvent;
|
|||||||
import se.su.dsv.scipro.project.Author;
|
import se.su.dsv.scipro.project.Author;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class FinalSeminarCreationSubscribers {
|
public class FinalSeminarCreationSubscribers {
|
||||||
|
|
||||||
private final AuthorRepository authorRepository;
|
private final AuthorRepository authorRepository;
|
||||||
private final FinalSeminarService finalSeminarService;
|
private final FinalSeminarService finalSeminarService;
|
||||||
private final NotificationController notificationController;
|
private final NotificationController notificationController;
|
||||||
|
|
||||||
FinalSeminarCreationSubscribers(
|
FinalSeminarCreationSubscribers(
|
||||||
AuthorRepository authorRepository,
|
AuthorRepository authorRepository,
|
||||||
FinalSeminarService finalSeminarService,
|
FinalSeminarService finalSeminarService,
|
||||||
NotificationController notificationController)
|
NotificationController notificationController
|
||||||
{
|
) {
|
||||||
this.authorRepository = authorRepository;
|
this.authorRepository = authorRepository;
|
||||||
this.finalSeminarService = finalSeminarService;
|
this.finalSeminarService = finalSeminarService;
|
||||||
this.notificationController = notificationController;
|
this.notificationController = notificationController;
|
||||||
@ -31,42 +31,59 @@ public class FinalSeminarCreationSubscribers {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarCreationSubscribers(
|
public FinalSeminarCreationSubscribers(
|
||||||
AuthorRepository authorRepository,
|
AuthorRepository authorRepository,
|
||||||
FinalSeminarService finalSeminarService,
|
FinalSeminarService finalSeminarService,
|
||||||
NotificationController notificationController,
|
NotificationController notificationController,
|
||||||
EventBus eventBus)
|
EventBus eventBus
|
||||||
{
|
) {
|
||||||
this(authorRepository, finalSeminarService, notificationController);
|
this(authorRepository, finalSeminarService, notificationController);
|
||||||
eventBus.register(this);
|
eventBus.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void finalSeminarCreated(FinalSeminarCreatedEvent event) {
|
public void finalSeminarCreated(FinalSeminarCreatedEvent event) {
|
||||||
List<Author> subscribers = authorRepository.getSubscribersWithActiveProjectOnType(event.getFinalSeminar().getProjectType());
|
List<Author> subscribers = authorRepository.getSubscribersWithActiveProjectOnType(
|
||||||
|
event.getFinalSeminar().getProjectType()
|
||||||
|
);
|
||||||
Set<Member> users = getSubscribersStillNeedingOppositionOrParticipation(subscribers)
|
Set<Member> users = getSubscribersStillNeedingOppositionOrParticipation(subscribers)
|
||||||
.stream()
|
.stream()
|
||||||
.map(user -> new Member(user, Member.Type.OPPONENT))
|
.map(user -> new Member(user, Member.Type.OPPONENT))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
notificationController.notifyCustomSeminar(event.getFinalSeminar(), SeminarEvent.Event.CREATED, new NotificationSource(), users);
|
notificationController.notifyCustomSeminar(
|
||||||
|
event.getFinalSeminar(),
|
||||||
|
SeminarEvent.Event.CREATED,
|
||||||
|
new NotificationSource(),
|
||||||
|
users
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<User> getSubscribersStillNeedingOppositionOrParticipation(List<Author> subscribers) {
|
private List<User> getSubscribersStillNeedingOppositionOrParticipation(
|
||||||
|
List<Author> subscribers
|
||||||
|
) {
|
||||||
return subscribers
|
return subscribers
|
||||||
.stream()
|
.stream()
|
||||||
.filter(subscriber -> onlyFailedOppositions(subscriber) || onlyFailedParticipations(subscriber))
|
.filter(
|
||||||
.map(Author::getUser)
|
subscriber ->
|
||||||
.toList();
|
onlyFailedOppositions(subscriber) || onlyFailedParticipations(subscriber)
|
||||||
|
)
|
||||||
|
.map(Author::getUser)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onlyFailedParticipations(Author subscriber) {
|
private boolean onlyFailedParticipations(Author subscriber) {
|
||||||
return finalSeminarService.findUserParticipating(subscriber.getProject(), subscriber.getUser())
|
return finalSeminarService
|
||||||
.stream()
|
.findUserParticipating(subscriber.getProject(), subscriber.getUser())
|
||||||
.noneMatch(FinalSeminarParticipation::isApproved);
|
.stream()
|
||||||
|
.noneMatch(FinalSeminarParticipation::isApproved);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onlyFailedOppositions(Author subscriber) {
|
private boolean onlyFailedOppositions(Author subscriber) {
|
||||||
return finalSeminarService.findFinalSeminarOppositionsByOpponentAndProjectType(subscriber.getProject().getProjectType(), subscriber.getUser())
|
return finalSeminarService
|
||||||
.stream()
|
.findFinalSeminarOppositionsByOpponentAndProjectType(
|
||||||
.noneMatch(FinalSeminarParticipation::isApproved);
|
subscriber.getProject().getProjectType(),
|
||||||
|
subscriber.getUser()
|
||||||
|
)
|
||||||
|
.stream()
|
||||||
|
.noneMatch(FinalSeminarParticipation::isApproved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,18 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
|
||||||
public final class FinalSeminarDeletedEvent {
|
public final class FinalSeminarDeletedEvent {
|
||||||
private final FinalSeminar finalSeminar;
|
|
||||||
|
|
||||||
public FinalSeminar getFinalSeminar(){
|
private final FinalSeminar finalSeminar;
|
||||||
|
|
||||||
|
public FinalSeminar getFinalSeminar() {
|
||||||
return finalSeminar;
|
return finalSeminar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FinalSeminarDeletedEvent(FinalSeminar finalSeminar) {
|
public FinalSeminarDeletedEvent(FinalSeminar finalSeminar) {
|
||||||
this.finalSeminar = finalSeminar;
|
this.finalSeminar = finalSeminar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project getProject() {
|
public Project getProject() {
|
||||||
return finalSeminar.getProject();
|
return finalSeminar.getProject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,11 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
import se.su.dsv.scipro.system.Language;
|
import se.su.dsv.scipro.system.Language;
|
||||||
|
|
||||||
public record FinalSeminarDetails(
|
public record FinalSeminarDetails(
|
||||||
String location,
|
String location,
|
||||||
Boolean manualParticipants,
|
Boolean manualParticipants,
|
||||||
int maxParticipants,
|
int maxParticipants,
|
||||||
int maxOpponents,
|
int maxOpponents,
|
||||||
Language presentationLanguage,
|
Language presentationLanguage,
|
||||||
Language reportLanguage,
|
Language reportLanguage,
|
||||||
String extraInfo)
|
String extraInfo
|
||||||
{
|
) {}
|
||||||
}
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
public enum FinalSeminarGrade {
|
public enum FinalSeminarGrade {
|
||||||
|
|
||||||
APPROVED {
|
APPROVED {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "approved";
|
return "approved";
|
||||||
}
|
}
|
||||||
}, NOT_APPROVED {
|
},
|
||||||
|
NOT_APPROVED {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "not approved";
|
return "not approved";
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,8 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
public record FinalSeminarMovedEvent(FinalSeminar finalSeminar, LocalDateTime from, LocalDateTime to) {
|
public record FinalSeminarMovedEvent(
|
||||||
}
|
FinalSeminar finalSeminar,
|
||||||
|
LocalDateTime from,
|
||||||
|
LocalDateTime to
|
||||||
|
) {}
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import se.su.dsv.scipro.file.FileReference;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.report.OppositionReport;
|
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
import jakarta.persistence.Basic;
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
@ -13,12 +8,16 @@ import jakarta.persistence.JoinColumn;
|
|||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToOne;
|
import jakarta.persistence.OneToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import se.su.dsv.scipro.file.FileReference;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.report.OppositionReport;
|
||||||
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="final_seminar_opposition")
|
@Table(name = "final_seminar_opposition")
|
||||||
public class FinalSeminarOpposition extends FinalSeminarParticipation {
|
public class FinalSeminarOpposition extends FinalSeminarParticipation {
|
||||||
|
|
||||||
private static final int FEEDBACK_LENGTH = 2000;
|
private static final int FEEDBACK_LENGTH = 2000;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
@ -47,8 +46,12 @@ public class FinalSeminarOpposition extends FinalSeminarParticipation {
|
|||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// JPA-mappings of other tables referencing to this table (final_seminar_opposition)
|
// JPA-mappings of other tables referencing to this table (final_seminar_opposition)
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
@OneToOne(optional = true, orphanRemoval = true, cascade = CascadeType.ALL,
|
@OneToOne(
|
||||||
mappedBy = "finalSeminarOpposition")
|
optional = true,
|
||||||
|
orphanRemoval = true,
|
||||||
|
cascade = CascadeType.ALL,
|
||||||
|
mappedBy = "finalSeminarOpposition"
|
||||||
|
)
|
||||||
private OppositionReport oppositionReport;
|
private OppositionReport oppositionReport;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
@ -102,9 +105,11 @@ public class FinalSeminarOpposition extends FinalSeminarParticipation {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof FinalSeminarOpposition)) return false;
|
if (!(o instanceof FinalSeminarOpposition)) return false;
|
||||||
final FinalSeminarOpposition other = (FinalSeminarOpposition) o;
|
final FinalSeminarOpposition other = (FinalSeminarOpposition) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& super.equals(o)
|
other.canEqual(this) &&
|
||||||
&& Objects.equals(this.getProject(), other.getProject());
|
super.equals(o) &&
|
||||||
|
Objects.equals(this.getProject(), other.getProject())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.util.*;
|
||||||
import se.su.dsv.scipro.system.JpaRepository;
|
import se.su.dsv.scipro.system.JpaRepository;
|
||||||
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
|
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public interface FinalSeminarOppositionRepo extends JpaRepository<FinalSeminarOpposition, Long>, QueryDslPredicateExecutor<FinalSeminarOpposition> {
|
public interface FinalSeminarOppositionRepo
|
||||||
|
extends
|
||||||
|
JpaRepository<FinalSeminarOpposition, Long>,
|
||||||
|
QueryDslPredicateExecutor<FinalSeminarOpposition> {
|
||||||
List<FinalSeminarOpposition> findByOpposingUserAndType(User user, ProjectType projectType);
|
List<FinalSeminarOpposition> findByOpposingUserAndType(User user, ProjectType projectType);
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,32 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.GenericRepo;
|
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import se.su.dsv.scipro.system.GenericRepo;
|
||||||
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
|
public class FinalSeminarOppositionRepoImpl
|
||||||
|
extends GenericRepo<FinalSeminarOpposition, Long>
|
||||||
|
implements FinalSeminarOppositionRepo {
|
||||||
|
|
||||||
public class FinalSeminarOppositionRepoImpl extends GenericRepo<FinalSeminarOpposition,Long> implements FinalSeminarOppositionRepo {
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarOppositionRepoImpl(Provider<EntityManager> em) {
|
public FinalSeminarOppositionRepoImpl(Provider<EntityManager> em) {
|
||||||
super(em, FinalSeminarOpposition.class, QFinalSeminarOpposition.finalSeminarOpposition);
|
super(em, FinalSeminarOpposition.class, QFinalSeminarOpposition.finalSeminarOpposition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FinalSeminarOpposition> findByOpposingUserAndType(User user, ProjectType projectType) {
|
public List<FinalSeminarOpposition> findByOpposingUserAndType(
|
||||||
|
User user,
|
||||||
|
ProjectType projectType
|
||||||
|
) {
|
||||||
return createQuery()
|
return createQuery()
|
||||||
.where(QFinalSeminarOpposition.finalSeminarOpposition.user.eq(user))
|
.where(QFinalSeminarOpposition.finalSeminarOpposition.user.eq(user))
|
||||||
.where(QFinalSeminarOpposition.finalSeminarOpposition.project.projectType.eq(projectType))
|
.where(
|
||||||
.fetch();
|
QFinalSeminarOpposition.finalSeminarOpposition.project.projectType.eq(projectType)
|
||||||
|
)
|
||||||
|
.fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,8 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
|
|
||||||
import se.su.dsv.scipro.system.GenericService;
|
import se.su.dsv.scipro.system.GenericService;
|
||||||
|
|
||||||
public interface FinalSeminarOppositionService extends GenericService<FinalSeminarOpposition, Long> {
|
public interface FinalSeminarOppositionService
|
||||||
|
extends GenericService<FinalSeminarOpposition, Long> {
|
||||||
@Override
|
@Override
|
||||||
void delete(Long aLong);
|
void delete(Long aLong);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
|
||||||
|
public class FinalSeminarOppositionServiceImpl
|
||||||
|
extends AbstractServiceImpl<FinalSeminarOpposition, Long>
|
||||||
|
implements FinalSeminarOppositionService {
|
||||||
|
|
||||||
public class FinalSeminarOppositionServiceImpl extends AbstractServiceImpl<FinalSeminarOpposition, Long> implements FinalSeminarOppositionService {
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarOppositionServiceImpl(Provider<EntityManager> em) {
|
public FinalSeminarOppositionServiceImpl(Provider<EntityManager> em) {
|
||||||
super(em, FinalSeminarOpposition.class, QFinalSeminarOpposition.finalSeminarOpposition);
|
super(em, FinalSeminarOpposition.class, QFinalSeminarOpposition.finalSeminarOpposition);
|
||||||
|
@ -10,13 +10,13 @@ import jakarta.persistence.Id;
|
|||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.MappedSuperclass;
|
import jakarta.persistence.MappedSuperclass;
|
||||||
|
import java.util.Objects;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class FinalSeminarParticipation extends DomainObject {
|
public abstract class FinalSeminarParticipation extends DomainObject {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// Basic JPA-mappings
|
// Basic JPA-mappings
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
@ -45,8 +45,7 @@ public abstract class FinalSeminarParticipation extends DomainObject {
|
|||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// Constructors
|
// Constructors
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
protected FinalSeminarParticipation() {
|
protected FinalSeminarParticipation() {}
|
||||||
}
|
|
||||||
|
|
||||||
protected FinalSeminarParticipation(User user, FinalSeminar finalSeminar) {
|
protected FinalSeminarParticipation(User user, FinalSeminar finalSeminar) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@ -97,9 +96,11 @@ public abstract class FinalSeminarParticipation extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof FinalSeminarParticipation)) return false;
|
if (!(o instanceof FinalSeminarParticipation)) return false;
|
||||||
final FinalSeminarParticipation other = (FinalSeminarParticipation) o;
|
final FinalSeminarParticipation other = (FinalSeminarParticipation) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& Objects.equals(this.getUser(), other.getUser())
|
other.canEqual(this) &&
|
||||||
&& Objects.equals(this.getFinalSeminar(), other.getFinalSeminar());
|
Objects.equals(this.getUser(), other.getUser()) &&
|
||||||
|
Objects.equals(this.getFinalSeminar(), other.getFinalSeminar())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import se.su.dsv.scipro.system.AbstractRepository;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import se.su.dsv.scipro.system.AbstractRepository;
|
||||||
|
|
||||||
|
public class FinalSeminarRepositoryImpl
|
||||||
|
extends AbstractRepository
|
||||||
|
implements FinalSeminarRepository {
|
||||||
|
|
||||||
public class FinalSeminarRepositoryImpl extends AbstractRepository implements FinalSeminarRepository {
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarRepositoryImpl(Provider<EntityManager> em) {
|
public FinalSeminarRepositoryImpl(Provider<EntityManager> em) {
|
||||||
super(em);
|
super(em);
|
||||||
@ -19,8 +21,7 @@ public class FinalSeminarRepositoryImpl extends AbstractRepository implements Fi
|
|||||||
EntityManager entityManager = em();
|
EntityManager entityManager = em();
|
||||||
if (entityManager.contains(finalSeminar)) {
|
if (entityManager.contains(finalSeminar)) {
|
||||||
return entityManager.merge(finalSeminar);
|
return entityManager.merge(finalSeminar);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
entityManager.persist(finalSeminar);
|
entityManager.persist(finalSeminar);
|
||||||
return finalSeminar;
|
return finalSeminar;
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.persistence.Cacheable;
|
import jakarta.persistence.Cacheable;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "final_seminar_respondent")
|
@Table(name = "final_seminar_respondent")
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
public class FinalSeminarRespondent extends FinalSeminarParticipation {
|
public class FinalSeminarRespondent extends FinalSeminarParticipation {
|
||||||
|
|
||||||
protected FinalSeminarRespondent() {
|
protected FinalSeminarRespondent() {}
|
||||||
}
|
|
||||||
|
|
||||||
public FinalSeminarRespondent(User student, FinalSeminar finalSeminar) {
|
public FinalSeminarRespondent(User student, FinalSeminar finalSeminar) {
|
||||||
super(student, finalSeminar);
|
super(student, finalSeminar);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import se.su.dsv.scipro.system.GenericService;
|
import se.su.dsv.scipro.system.GenericService;
|
||||||
|
|
||||||
import java.util.List;
|
public interface FinalSeminarRespondentService
|
||||||
|
extends GenericService<FinalSeminarRespondent, Long> {
|
||||||
public interface FinalSeminarRespondentService extends GenericService<FinalSeminarRespondent, Long> {
|
|
||||||
List<FinalSeminarRespondent> findOrCreate(FinalSeminar finalSeminar);
|
List<FinalSeminarRespondent> findOrCreate(FinalSeminar finalSeminar);
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
import static com.querydsl.core.types.dsl.Expressions.allOf;
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Named;
|
import jakarta.inject.Named;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
import static com.querydsl.core.types.dsl.Expressions.allOf;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@Named
|
@Named
|
||||||
public class FinalSeminarRespondentServiceImpl extends AbstractServiceImpl<FinalSeminarRespondent, Long> implements FinalSeminarRespondentService {
|
public class FinalSeminarRespondentServiceImpl
|
||||||
|
extends AbstractServiceImpl<FinalSeminarRespondent, Long>
|
||||||
|
implements FinalSeminarRespondentService {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarRespondentServiceImpl(Provider<EntityManager> em) {
|
public FinalSeminarRespondentServiceImpl(Provider<EntityManager> em) {
|
||||||
@ -23,9 +24,12 @@ public class FinalSeminarRespondentServiceImpl extends AbstractServiceImpl<Final
|
|||||||
}
|
}
|
||||||
|
|
||||||
private FinalSeminarRespondent findOrCreate(User student, FinalSeminar finalSeminar) {
|
private FinalSeminarRespondent findOrCreate(User student, FinalSeminar finalSeminar) {
|
||||||
FinalSeminarRespondent finalSeminarRespondent = findOne(allOf(
|
FinalSeminarRespondent finalSeminarRespondent = findOne(
|
||||||
|
allOf(
|
||||||
QFinalSeminarRespondent.finalSeminarRespondent.user.eq(student),
|
QFinalSeminarRespondent.finalSeminarRespondent.user.eq(student),
|
||||||
QFinalSeminarRespondent.finalSeminarRespondent.finalSeminar.eq(finalSeminar)));
|
QFinalSeminarRespondent.finalSeminarRespondent.finalSeminar.eq(finalSeminar)
|
||||||
|
)
|
||||||
|
);
|
||||||
if (finalSeminarRespondent == null) {
|
if (finalSeminarRespondent == null) {
|
||||||
finalSeminarRespondent = new FinalSeminarRespondent(student, finalSeminar);
|
finalSeminarRespondent = new FinalSeminarRespondent(student, finalSeminar);
|
||||||
return save(finalSeminarRespondent);
|
return save(finalSeminarRespondent);
|
||||||
@ -36,7 +40,7 @@ public class FinalSeminarRespondentServiceImpl extends AbstractServiceImpl<Final
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<FinalSeminarRespondent> findOrCreate(FinalSeminar finalSeminar) {
|
public List<FinalSeminarRespondent> findOrCreate(FinalSeminar finalSeminar) {
|
||||||
if(finalSeminar.getId() == null) {
|
if (finalSeminar.getId() == null) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
List<FinalSeminarRespondent> finalSeminarRespondents = new ArrayList<>();
|
List<FinalSeminarRespondent> finalSeminarRespondents = new ArrayList<>();
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.util.Either;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.util.Either;
|
||||||
|
|
||||||
public interface FinalSeminarScheduling {
|
public interface FinalSeminarScheduling {
|
||||||
Either<SchedulingError, FinalSeminar> schedule(Project project, LocalDateTime when, FinalSeminarDetails details);
|
Either<SchedulingError, FinalSeminar> schedule(
|
||||||
|
Project project,
|
||||||
|
LocalDateTime when,
|
||||||
|
FinalSeminarDetails details
|
||||||
|
);
|
||||||
|
|
||||||
LocalDate getEarliestSeminarDate();
|
LocalDate getEarliestSeminarDate();
|
||||||
|
|
||||||
|
@ -1,28 +1,55 @@
|
|||||||
|
|
||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.system.*;
|
|
||||||
import se.su.dsv.scipro.util.Either;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.*;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
|
import se.su.dsv.scipro.util.Either;
|
||||||
|
|
||||||
public interface FinalSeminarService extends GenericService<FinalSeminar, Long>, FilteredService<FinalSeminar, Long, FinalSeminarService.Filter>, FinalSeminarScheduling {
|
public interface FinalSeminarService
|
||||||
Either<OppositionRegistrationErrorStatus, FinalSeminarOpposition> attemptAddOpposition(User student, FinalSeminar finalSeminar, Project project);
|
extends
|
||||||
|
GenericService<FinalSeminar, Long>,
|
||||||
|
FilteredService<FinalSeminar, Long, FinalSeminarService.Filter>,
|
||||||
|
FinalSeminarScheduling {
|
||||||
|
Either<OppositionRegistrationErrorStatus, FinalSeminarOpposition> attemptAddOpposition(
|
||||||
|
User student,
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
Project project
|
||||||
|
);
|
||||||
|
|
||||||
Either<ActiveParticipationRegistrationErrorStatus, FinalSeminarActiveParticipation> attemptAddActiveParticipation(User student, FinalSeminar finalSeminar, Project project);
|
Either<
|
||||||
|
ActiveParticipationRegistrationErrorStatus,
|
||||||
|
FinalSeminarActiveParticipation
|
||||||
|
> attemptAddActiveParticipation(User student, FinalSeminar finalSeminar, Project project);
|
||||||
|
|
||||||
Either<OpposeError, FinalSeminarOpposition> attemptAddOppositionAsSupervisor(User student, FinalSeminar finalSeminar, Project project);
|
Either<OpposeError, FinalSeminarOpposition> attemptAddOppositionAsSupervisor(
|
||||||
|
User student,
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
Project project
|
||||||
|
);
|
||||||
|
|
||||||
Either<ParticipateError, FinalSeminarActiveParticipation> attemptAddActiveParticipationAsSupervisor(User student, FinalSeminar finalSeminar, Project project);
|
Either<
|
||||||
|
ParticipateError,
|
||||||
|
FinalSeminarActiveParticipation
|
||||||
|
> attemptAddActiveParticipationAsSupervisor(
|
||||||
|
User student,
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
Project project
|
||||||
|
);
|
||||||
|
|
||||||
Either<OppositionRegistrationErrorStatus, Void> canOppose(User Student, FinalSeminar finalSeminar, Project project);
|
Either<OppositionRegistrationErrorStatus, Void> canOppose(
|
||||||
|
User Student,
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
Project project
|
||||||
|
);
|
||||||
|
|
||||||
Either<ActiveParticipationRegistrationErrorStatus, Void> canActiveParticipate(User student, FinalSeminar finalSeminar);
|
Either<ActiveParticipationRegistrationErrorStatus, Void> canActiveParticipate(
|
||||||
|
User student,
|
||||||
|
FinalSeminar finalSeminar
|
||||||
|
);
|
||||||
|
|
||||||
Iterable<FinalSeminar> findAll(Filter params);
|
Iterable<FinalSeminar> findAll(Filter params);
|
||||||
|
|
||||||
@ -51,7 +78,10 @@ public interface FinalSeminarService extends GenericService<FinalSeminar, Long>,
|
|||||||
|
|
||||||
FinalSeminar cancel(FinalSeminar finalSeminar);
|
FinalSeminar cancel(FinalSeminar finalSeminar);
|
||||||
|
|
||||||
List<FinalSeminarOpposition> findFinalSeminarOppositionsByOpponentAndProjectType(ProjectType projectType, User user);
|
List<FinalSeminarOpposition> findFinalSeminarOppositionsByOpponentAndProjectType(
|
||||||
|
ProjectType projectType,
|
||||||
|
User user
|
||||||
|
);
|
||||||
|
|
||||||
List<FinalSeminarActiveParticipation> findUserParticipating(Project project, User user);
|
List<FinalSeminarActiveParticipation> findUserParticipating(Project project, User user);
|
||||||
|
|
||||||
@ -60,6 +90,7 @@ public interface FinalSeminarService extends GenericService<FinalSeminar, Long>,
|
|||||||
void toggleSubscriptionToSeminarCreationNotifications(Project project, User user);
|
void toggleSubscriptionToSeminarCreationNotifications(Project project, User user);
|
||||||
|
|
||||||
class Filter implements Serializable {
|
class Filter implements Serializable {
|
||||||
|
|
||||||
private Date fromDate;
|
private Date fromDate;
|
||||||
private Date toDate;
|
private Date toDate;
|
||||||
private Boolean lazyDeleted;
|
private Boolean lazyDeleted;
|
||||||
@ -147,16 +178,21 @@ public interface FinalSeminarService extends GenericService<FinalSeminar, Long>,
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof Filter)) return false;
|
if (!(o instanceof Filter)) return false;
|
||||||
final Filter other = (Filter) o;
|
final Filter other = (Filter) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& Objects.equals(this.getFromDate(), other.getFromDate())
|
other.canEqual(this) &&
|
||||||
&& Objects.equals(this.getToDate(), other.getToDate())
|
Objects.equals(this.getFromDate(), other.getFromDate()) &&
|
||||||
&& Objects.equals(this.getLazyDeleted(), other.getLazyDeleted())
|
Objects.equals(this.getToDate(), other.getToDate()) &&
|
||||||
&& Objects.equals(this.getExempted(), other.getExempted())
|
Objects.equals(this.getLazyDeleted(), other.getLazyDeleted()) &&
|
||||||
&& Objects.equals(this.getOnlyActiveProjects(), other.getOnlyActiveProjects())
|
Objects.equals(this.getExempted(), other.getExempted()) &&
|
||||||
&& Objects.equals(this.getOnlyActiveOrCompletedProjects(), other.getOnlyActiveOrCompletedProjects())
|
Objects.equals(this.getOnlyActiveProjects(), other.getOnlyActiveProjects()) &&
|
||||||
&& Objects.equals(this.getHeadSupervisor(), other.getHeadSupervisor())
|
Objects.equals(
|
||||||
&& Objects.equals(this.getDegreeType(), other.getDegreeType())
|
this.getOnlyActiveOrCompletedProjects(),
|
||||||
&& Objects.equals(this.onlyNonManualParticipants, other.onlyNonManualParticipants);
|
other.getOnlyActiveOrCompletedProjects()
|
||||||
|
) &&
|
||||||
|
Objects.equals(this.getHeadSupervisor(), other.getHeadSupervisor()) &&
|
||||||
|
Objects.equals(this.getDegreeType(), other.getDegreeType()) &&
|
||||||
|
Objects.equals(this.onlyNonManualParticipants, other.onlyNonManualParticipants)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
@ -166,29 +202,42 @@ public interface FinalSeminarService extends GenericService<FinalSeminar, Long>,
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
this.getFromDate(),
|
this.getFromDate(),
|
||||||
this.getToDate(),
|
this.getToDate(),
|
||||||
this.getLazyDeleted(),
|
this.getLazyDeleted(),
|
||||||
this.getExempted(),
|
this.getExempted(),
|
||||||
this.getOnlyActiveProjects(),
|
this.getOnlyActiveProjects(),
|
||||||
this.getOnlyActiveOrCompletedProjects(),
|
this.getOnlyActiveOrCompletedProjects(),
|
||||||
this.getHeadSupervisor(),
|
this.getHeadSupervisor(),
|
||||||
this.getDegreeType(),
|
this.getDegreeType(),
|
||||||
this.getOnlyNonManualParticipants());
|
this.getOnlyNonManualParticipants()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FinalSeminarService.Filter(" +
|
return (
|
||||||
"fromDate=" + this.getFromDate()
|
"FinalSeminarService.Filter(" +
|
||||||
+ ", toDate=" + this.getToDate()
|
"fromDate=" +
|
||||||
+ ", lazyDeleted=" + this.getLazyDeleted()
|
this.getFromDate() +
|
||||||
+ ", exempted=" + this.getExempted()
|
", toDate=" +
|
||||||
+ ", onlyActiveProjects=" + this.getOnlyActiveProjects()
|
this.getToDate() +
|
||||||
+ ", onlyActiveOrCompletedProjects=" + this.getOnlyActiveOrCompletedProjects()
|
", lazyDeleted=" +
|
||||||
+ ", headSupervisor=" + this.getHeadSupervisor()
|
this.getLazyDeleted() +
|
||||||
+ ", degreeType=" + this.getDegreeType()
|
", exempted=" +
|
||||||
+ ", onlyNonManualParticipants=" + this.getOnlyNonManualParticipants() + ")";
|
this.getExempted() +
|
||||||
|
", onlyActiveProjects=" +
|
||||||
|
this.getOnlyActiveProjects() +
|
||||||
|
", onlyActiveOrCompletedProjects=" +
|
||||||
|
this.getOnlyActiveOrCompletedProjects() +
|
||||||
|
", headSupervisor=" +
|
||||||
|
this.getHeadSupervisor() +
|
||||||
|
", degreeType=" +
|
||||||
|
this.getDegreeType() +
|
||||||
|
", onlyNonManualParticipants=" +
|
||||||
|
this.getOnlyNonManualParticipants() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import com.querydsl.core.BooleanBuilder;
|
import com.querydsl.core.BooleanBuilder;
|
||||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import se.su.dsv.scipro.system.Pageable;
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.time.*;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import se.su.dsv.scipro.file.FileReference;
|
import se.su.dsv.scipro.file.FileReference;
|
||||||
import se.su.dsv.scipro.file.FileService;
|
import se.su.dsv.scipro.file.FileService;
|
||||||
import se.su.dsv.scipro.misc.DaysService;
|
import se.su.dsv.scipro.misc.DaysService;
|
||||||
@ -17,25 +22,24 @@ import se.su.dsv.scipro.report.OppositionReportService;
|
|||||||
import se.su.dsv.scipro.reviewing.RoughDraftApproval;
|
import se.su.dsv.scipro.reviewing.RoughDraftApproval;
|
||||||
import se.su.dsv.scipro.reviewing.RoughDraftApprovalService;
|
import se.su.dsv.scipro.reviewing.RoughDraftApprovalService;
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
import se.su.dsv.scipro.system.Pageable;
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
import se.su.dsv.scipro.util.Either;
|
import se.su.dsv.scipro.util.Either;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
public class FinalSeminarServiceImpl
|
||||||
import jakarta.inject.Provider;
|
extends AbstractServiceImpl<FinalSeminar, Long>
|
||||||
import java.time.*;
|
implements FinalSeminarService {
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, Long> implements FinalSeminarService {
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
FinalSeminarSettingsService finalSeminarSettingsService;
|
FinalSeminarSettingsService finalSeminarSettingsService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DaysService daysService;
|
DaysService daysService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
OppositionReportService oppositionReportService;
|
OppositionReportService oppositionReportService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
NonWorkDayPeriodService nonWorkDayPeriodService;
|
NonWorkDayPeriodService nonWorkDayPeriodService;
|
||||||
|
|
||||||
@ -50,15 +54,16 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarServiceImpl(
|
public FinalSeminarServiceImpl(
|
||||||
Provider<EntityManager> em,
|
Provider<EntityManager> em,
|
||||||
EventBus eventBus,
|
EventBus eventBus,
|
||||||
AuthorRepository authorRepository,
|
AuthorRepository authorRepository,
|
||||||
final FileService fileService,
|
final FileService fileService,
|
||||||
FinalSeminarOppositionRepo finalSeminarOppositionRepository,
|
FinalSeminarOppositionRepo finalSeminarOppositionRepository,
|
||||||
FinalSeminarActiveParticipationRepository finalSeminarActiveParticipationRepository,
|
FinalSeminarActiveParticipationRepository finalSeminarActiveParticipationRepository,
|
||||||
FinalSeminarRepository finalSeminarRepository,
|
FinalSeminarRepository finalSeminarRepository,
|
||||||
Clock clock,
|
Clock clock,
|
||||||
RoughDraftApprovalService roughDraftApprovalService) {
|
RoughDraftApprovalService roughDraftApprovalService
|
||||||
|
) {
|
||||||
super(em, FinalSeminar.class, QFinalSeminar.finalSeminar);
|
super(em, FinalSeminar.class, QFinalSeminar.finalSeminar);
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.authorRepository = authorRepository;
|
this.authorRepository = authorRepository;
|
||||||
@ -72,7 +77,11 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Either<SchedulingError, FinalSeminar> schedule(Project project, LocalDateTime when, FinalSeminarDetails details) {
|
public Either<SchedulingError, FinalSeminar> schedule(
|
||||||
|
Project project,
|
||||||
|
LocalDateTime when,
|
||||||
|
FinalSeminarDetails details
|
||||||
|
) {
|
||||||
if (project.isFinalSeminarRuleExempted()) {
|
if (project.isFinalSeminarRuleExempted()) {
|
||||||
return createSeminar(project, when, details);
|
return createSeminar(project, when, details);
|
||||||
}
|
}
|
||||||
@ -80,9 +89,10 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
SchedulingError violation = validateSchedulingRules(when.toLocalDate());
|
SchedulingError violation = validateSchedulingRules(when.toLocalDate());
|
||||||
if (violation != null) return Either.left(violation);
|
if (violation != null) return Either.left(violation);
|
||||||
|
|
||||||
boolean roughDraftApproved = roughDraftApprovalService.findBy(project)
|
boolean roughDraftApproved = roughDraftApprovalService
|
||||||
.map(RoughDraftApproval::isApproved)
|
.findBy(project)
|
||||||
.orElse(Boolean.FALSE);
|
.map(RoughDraftApproval::isApproved)
|
||||||
|
.orElse(Boolean.FALSE);
|
||||||
if (!roughDraftApproved) {
|
if (!roughDraftApproved) {
|
||||||
return Either.left(new RoughDraftNotApproved());
|
return Either.left(new RoughDraftNotApproved());
|
||||||
}
|
}
|
||||||
@ -90,8 +100,7 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
final FinalSeminar current = findByProject(project);
|
final FinalSeminar current = findByProject(project);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
return createSeminar(project, when, details);
|
return createSeminar(project, when, details);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Assume double click sends the same data so no need to change anything
|
// Assume double click sends the same data so no need to change anything
|
||||||
return Either.right(current);
|
return Either.right(current);
|
||||||
}
|
}
|
||||||
@ -116,16 +125,21 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Either<SchedulingError, FinalSeminar> createSeminar(
|
private Either<SchedulingError, FinalSeminar> createSeminar(
|
||||||
Project project,
|
Project project,
|
||||||
LocalDateTime when,
|
LocalDateTime when,
|
||||||
FinalSeminarDetails details) {
|
FinalSeminarDetails details
|
||||||
|
) {
|
||||||
FinalSeminar finalSeminar = new FinalSeminar(project);
|
FinalSeminar finalSeminar = new FinalSeminar(project);
|
||||||
FinalSeminar persisted = setDetails(finalSeminar, when, details);
|
FinalSeminar persisted = setDetails(finalSeminar, when, details);
|
||||||
eventBus.post(new FinalSeminarCreatedEvent(persisted));
|
eventBus.post(new FinalSeminarCreatedEvent(persisted));
|
||||||
return Either.right(persisted);
|
return Either.right(persisted);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FinalSeminar setDetails(FinalSeminar finalSeminar, LocalDateTime when, FinalSeminarDetails details) {
|
private FinalSeminar setDetails(
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
LocalDateTime when,
|
||||||
|
FinalSeminarDetails details
|
||||||
|
) {
|
||||||
Instant instant = when.atZone(clock.getZone()).toInstant();
|
Instant instant = when.atZone(clock.getZone()).toInstant();
|
||||||
finalSeminar.setStartDate(Date.from(instant));
|
finalSeminar.setStartDate(Date.from(instant));
|
||||||
return updateDetails(finalSeminar, details);
|
return updateDetails(finalSeminar, details);
|
||||||
@ -144,7 +158,10 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
return moveSeminar(finalSeminar, to);
|
return moveSeminar(finalSeminar, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Either<MovingError, FinalSeminar> moveSeminar(FinalSeminar finalSeminar, LocalDateTime to) {
|
private Either<MovingError, FinalSeminar> moveSeminar(
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
LocalDateTime to
|
||||||
|
) {
|
||||||
ZonedDateTime oldTime = finalSeminar.getStartDate().toInstant().atZone(clock.getZone());
|
ZonedDateTime oldTime = finalSeminar.getStartDate().toInstant().atZone(clock.getZone());
|
||||||
Instant instant = to.atZone(clock.getZone()).toInstant();
|
Instant instant = to.atZone(clock.getZone()).toInstant();
|
||||||
finalSeminar.setStartDate(Date.from(instant));
|
finalSeminar.setStartDate(Date.from(instant));
|
||||||
@ -156,7 +173,10 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public FinalSeminar updateDetails(FinalSeminar finalSeminar, FinalSeminarDetails finalSeminarDetails) {
|
public FinalSeminar updateDetails(
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
FinalSeminarDetails finalSeminarDetails
|
||||||
|
) {
|
||||||
finalSeminar.setRoom(finalSeminarDetails.location());
|
finalSeminar.setRoom(finalSeminarDetails.location());
|
||||||
finalSeminar.setExtraInfo(finalSeminarDetails.extraInfo());
|
finalSeminar.setExtraInfo(finalSeminarDetails.extraInfo());
|
||||||
finalSeminar.setManualParticipants(finalSeminarDetails.manualParticipants());
|
finalSeminar.setManualParticipants(finalSeminarDetails.manualParticipants());
|
||||||
@ -211,7 +231,11 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Either<OppositionRegistrationErrorStatus, Void> canOppose(User Student, FinalSeminar finalSeminar, Project project) {
|
public Either<OppositionRegistrationErrorStatus, Void> canOppose(
|
||||||
|
User Student,
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
Project project
|
||||||
|
) {
|
||||||
if (finalSeminar.isCancelled()) {
|
if (finalSeminar.isCancelled()) {
|
||||||
return Either.left(new FinalSeminarCancelled());
|
return Either.left(new FinalSeminarCancelled());
|
||||||
}
|
}
|
||||||
@ -227,14 +251,19 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
if (finalSeminar.getOppositions().size() >= finalSeminar.getMaxOpponents()) {
|
if (finalSeminar.getOppositions().size() >= finalSeminar.getMaxOpponents()) {
|
||||||
return Either.left(new TooManyOpponents());
|
return Either.left(new TooManyOpponents());
|
||||||
}
|
}
|
||||||
for (FinalSeminarOpposition opposition : finalSeminarOppositionRepository.findByOpposingUserAndType(Student, project.getProjectType())) {
|
for (FinalSeminarOpposition opposition : finalSeminarOppositionRepository.findByOpposingUserAndType(
|
||||||
|
Student,
|
||||||
|
project.getProjectType()
|
||||||
|
)) {
|
||||||
if (opposition.getGrade() == null) {
|
if (opposition.getGrade() == null) {
|
||||||
return Either.left(new UngradedOpposition());
|
return Either.left(new UngradedOpposition());
|
||||||
} else if (opposition.getGrade() == FinalSeminarGrade.APPROVED) {
|
} else if (opposition.getGrade() == FinalSeminarGrade.APPROVED) {
|
||||||
return Either.left(new AlreadyOpposed());
|
return Either.left(new AlreadyOpposed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int oppositionPriorityDays = finalSeminarSettingsService.getInstance().getOppositionPriorityDays();
|
int oppositionPriorityDays = finalSeminarSettingsService
|
||||||
|
.getInstance()
|
||||||
|
.getOppositionPriorityDays();
|
||||||
final Instant seminarDate = finalSeminar.getDateCreated().toInstant();
|
final Instant seminarDate = finalSeminar.getDateCreated().toInstant();
|
||||||
final Instant available = seminarDate.plus(Period.ofDays(oppositionPriorityDays));
|
final Instant available = seminarDate.plus(Period.ofDays(oppositionPriorityDays));
|
||||||
if (available.isAfter(Instant.now()) && findByProject(project) == null) {
|
if (available.isAfter(Instant.now()) && findByProject(project) == null) {
|
||||||
@ -244,7 +273,10 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Either<ActiveParticipationRegistrationErrorStatus, Void> canActiveParticipate(User student, FinalSeminar finalSeminar) {
|
public Either<ActiveParticipationRegistrationErrorStatus, Void> canActiveParticipate(
|
||||||
|
User student,
|
||||||
|
FinalSeminar finalSeminar
|
||||||
|
) {
|
||||||
if (finalSeminar.getManualParticipants()) {
|
if (finalSeminar.getManualParticipants()) {
|
||||||
return Either.left(new ManualParticipants());
|
return Either.left(new ManualParticipants());
|
||||||
}
|
}
|
||||||
@ -264,20 +296,32 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean alreadyParticipatingInSeminar(User user, FinalSeminar finalSeminar) {
|
private boolean alreadyParticipatingInSeminar(User user, FinalSeminar finalSeminar) {
|
||||||
return alreadyOpponent(user, finalSeminar) || isAuthor(user, finalSeminar) || alreadyActiveParticipant(user, finalSeminar);
|
return (
|
||||||
|
alreadyOpponent(user, finalSeminar) ||
|
||||||
|
isAuthor(user, finalSeminar) ||
|
||||||
|
alreadyActiveParticipant(user, finalSeminar)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Either<OppositionRegistrationErrorStatus, FinalSeminarOpposition> attemptAddOpposition(final User student, final FinalSeminar finalSeminar, final Project project) {
|
public Either<OppositionRegistrationErrorStatus, FinalSeminarOpposition> attemptAddOpposition(
|
||||||
return canOppose(student, finalSeminar, project)
|
final User student,
|
||||||
.map(allowed -> createAndSaveOpposition(student, finalSeminar, project));
|
final FinalSeminar finalSeminar,
|
||||||
|
final Project project
|
||||||
|
) {
|
||||||
|
return canOppose(student, finalSeminar, project).map(allowed ->
|
||||||
|
createAndSaveOpposition(student, finalSeminar, project)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Either<OpposeError, FinalSeminarOpposition> attemptAddOppositionAsSupervisor(User student, FinalSeminar finalSeminar, Project project) {
|
public Either<OpposeError, FinalSeminarOpposition> attemptAddOppositionAsSupervisor(
|
||||||
|
User student,
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
Project project
|
||||||
|
) {
|
||||||
if (alreadyActiveParticipant(student, finalSeminar)) {
|
if (alreadyActiveParticipant(student, finalSeminar)) {
|
||||||
return Either.left(OpposeError.ALREADY_PARTICIPANT);
|
return Either.left(OpposeError.ALREADY_PARTICIPANT);
|
||||||
} else if (alreadyOpponent(student, finalSeminar)) {
|
} else if (alreadyOpponent(student, finalSeminar)) {
|
||||||
@ -289,7 +333,11 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FinalSeminarOpposition createAndSaveOpposition(User student, FinalSeminar finalSeminar, Project project) {
|
private FinalSeminarOpposition createAndSaveOpposition(
|
||||||
|
User student,
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
Project project
|
||||||
|
) {
|
||||||
FinalSeminarOpposition opposition = new FinalSeminarOpposition();
|
FinalSeminarOpposition opposition = new FinalSeminarOpposition();
|
||||||
opposition.setUser(student);
|
opposition.setUser(student);
|
||||||
opposition.setFinalSeminar(finalSeminar);
|
opposition.setFinalSeminar(finalSeminar);
|
||||||
@ -301,14 +349,29 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Either<ActiveParticipationRegistrationErrorStatus, FinalSeminarActiveParticipation> attemptAddActiveParticipation(final User student, final FinalSeminar finalSeminar, final Project project) {
|
public Either<
|
||||||
return canActiveParticipate(student, finalSeminar)
|
ActiveParticipationRegistrationErrorStatus,
|
||||||
.map(allowed -> createAndSaveActiveParticipation(student, finalSeminar, project));
|
FinalSeminarActiveParticipation
|
||||||
|
> attemptAddActiveParticipation(
|
||||||
|
final User student,
|
||||||
|
final FinalSeminar finalSeminar,
|
||||||
|
final Project project
|
||||||
|
) {
|
||||||
|
return canActiveParticipate(student, finalSeminar).map(allowed ->
|
||||||
|
createAndSaveActiveParticipation(student, finalSeminar, project)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Either<ParticipateError, FinalSeminarActiveParticipation> attemptAddActiveParticipationAsSupervisor(User student, FinalSeminar finalSeminar, Project project) {
|
public Either<
|
||||||
|
ParticipateError,
|
||||||
|
FinalSeminarActiveParticipation
|
||||||
|
> attemptAddActiveParticipationAsSupervisor(
|
||||||
|
User student,
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
Project project
|
||||||
|
) {
|
||||||
if (alreadyActiveParticipant(student, finalSeminar)) {
|
if (alreadyActiveParticipant(student, finalSeminar)) {
|
||||||
return Either.left(ParticipateError.ALREADY_PARTICIPANT);
|
return Either.left(ParticipateError.ALREADY_PARTICIPANT);
|
||||||
} else if (alreadyOpponent(student, finalSeminar)) {
|
} else if (alreadyOpponent(student, finalSeminar)) {
|
||||||
@ -320,7 +383,11 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FinalSeminarActiveParticipation createAndSaveActiveParticipation(User student, FinalSeminar finalSeminar, Project project) {
|
private FinalSeminarActiveParticipation createAndSaveActiveParticipation(
|
||||||
|
User student,
|
||||||
|
FinalSeminar finalSeminar,
|
||||||
|
Project project
|
||||||
|
) {
|
||||||
FinalSeminarActiveParticipation activeParticipation = new FinalSeminarActiveParticipation();
|
FinalSeminarActiveParticipation activeParticipation = new FinalSeminarActiveParticipation();
|
||||||
activeParticipation.setUser(student);
|
activeParticipation.setUser(student);
|
||||||
activeParticipation.setFinalSeminar(finalSeminar);
|
activeParticipation.setFinalSeminar(finalSeminar);
|
||||||
@ -337,7 +404,10 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date thesisUploadDeadline(FinalSeminar finalSeminar) {
|
public Date thesisUploadDeadline(FinalSeminar finalSeminar) {
|
||||||
return daysService.workDaysAhead(finalSeminar.getStartDate(), finalSeminarSettingsService.getInstance().getDaysAheadToUploadThesis());
|
return daysService.workDaysAhead(
|
||||||
|
finalSeminar.getStartDate(),
|
||||||
|
finalSeminarSettingsService.getInstance().getDaysAheadToUploadThesis()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -348,7 +418,7 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasThesis(FinalSeminar finalSeminar) {
|
public boolean hasThesis(FinalSeminar finalSeminar) {
|
||||||
FileReference fileDescription = finalSeminar.getDocument();
|
FileReference fileDescription = finalSeminar.getDocument();
|
||||||
return fileDescription != null && fileService.isDataAvailable(fileDescription);
|
return (fileDescription != null && fileService.isDataAvailable(fileDescription));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -385,7 +455,9 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
bb.and(onlyNonManualParticipantsFilter());
|
bb.and(onlyNonManualParticipantsFilter());
|
||||||
}
|
}
|
||||||
if (params.getDegreeType() != null) {
|
if (params.getDegreeType() != null) {
|
||||||
bb.and(QFinalSeminar.finalSeminar.project.projectType.degreeType.eq(params.getDegreeType()));
|
bb.and(
|
||||||
|
QFinalSeminar.finalSeminar.project.projectType.degreeType.eq(params.getDegreeType())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (params.getHeadSupervisor() != null) {
|
if (params.getHeadSupervisor() != null) {
|
||||||
bb.and(hasHeadSupervisor(params.getHeadSupervisor()));
|
bb.and(hasHeadSupervisor(params.getHeadSupervisor()));
|
||||||
@ -393,7 +465,6 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private BooleanExpression hasHeadSupervisor(User headSupervisor) {
|
private BooleanExpression hasHeadSupervisor(User headSupervisor) {
|
||||||
return QFinalSeminar.finalSeminar.project.headSupervisor.eq(headSupervisor);
|
return QFinalSeminar.finalSeminar.project.headSupervisor.eq(headSupervisor);
|
||||||
}
|
}
|
||||||
@ -407,7 +478,10 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BooleanExpression onlyActiveOrCompletedProjectsFilter() {
|
private BooleanExpression onlyActiveOrCompletedProjectsFilter() {
|
||||||
return QFinalSeminar.finalSeminar.project.projectStatus.in(ProjectStatus.ACTIVE, ProjectStatus.COMPLETED);
|
return QFinalSeminar.finalSeminar.project.projectStatus.in(
|
||||||
|
ProjectStatus.ACTIVE,
|
||||||
|
ProjectStatus.COMPLETED
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -430,17 +504,26 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FinalSeminarOpposition> getOppositionsByProjectAuthors(Project project) {
|
public List<FinalSeminarOpposition> getOppositionsByProjectAuthors(Project project) {
|
||||||
return project.getProjectParticipants()
|
return project
|
||||||
.stream()
|
.getProjectParticipants()
|
||||||
.map(author -> findFinalSeminarOppositionsByOpponentAndProjectType(project.getProjectType(), author))
|
.stream()
|
||||||
.flatMap(List::stream)
|
.map(author ->
|
||||||
.toList();
|
findFinalSeminarOppositionsByOpponentAndProjectType(
|
||||||
|
project.getProjectType(),
|
||||||
|
author
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.flatMap(List::stream)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasHadFinalSeminar(Project project) {
|
public boolean hasHadFinalSeminar(Project project) {
|
||||||
FinalSeminar finalSeminar = findByProject(project);
|
FinalSeminar finalSeminar = findByProject(project);
|
||||||
return finalSeminar != null && finalSeminar.getStartDate().toInstant().isBefore(clock.instant());
|
return (
|
||||||
|
finalSeminar != null &&
|
||||||
|
finalSeminar.getStartDate().toInstant().isBefore(clock.instant())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -463,39 +546,59 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FinalSeminarOpposition> findFinalSeminarOppositionsByOpponentAndProjectType(ProjectType projectType, User user) {
|
public List<FinalSeminarOpposition> findFinalSeminarOppositionsByOpponentAndProjectType(
|
||||||
|
ProjectType projectType,
|
||||||
|
User user
|
||||||
|
) {
|
||||||
return finalSeminarOppositionRepository.findByOpposingUserAndType(user, projectType);
|
return finalSeminarOppositionRepository.findByOpposingUserAndType(user, projectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FinalSeminarActiveParticipation> findUserParticipating(Project project, User user) {
|
public List<FinalSeminarActiveParticipation> findUserParticipating(Project project, User user) {
|
||||||
return finalSeminarActiveParticipationRepository.findByParticipatingUserAndLevel(user, project.getProjectType());
|
return finalSeminarActiveParticipationRepository.findByParticipatingUserAndLevel(
|
||||||
|
user,
|
||||||
|
project.getProjectType()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSubscribedToSeminarCreationNotifications(Project project, User user) {
|
public boolean isSubscribedToSeminarCreationNotifications(Project project, User user) {
|
||||||
final Optional<Author> author = authorRepository.findByProjectAndUser(project, user);
|
final Optional<Author> author = authorRepository.findByProjectAndUser(project, user);
|
||||||
return author.isPresent() && author.get().isSubscribedToFinalSeminarNotifications();
|
return (author.isPresent() && author.get().isSubscribedToFinalSeminarNotifications());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void toggleSubscriptionToSeminarCreationNotifications(Project project, User user) {
|
public void toggleSubscriptionToSeminarCreationNotifications(Project project, User user) {
|
||||||
authorRepository.findByProjectAndUser(project, user)
|
authorRepository
|
||||||
.ifPresent(author -> author.setSubscribedToFinalSeminarNotifications(!author.isSubscribedToFinalSeminarNotifications()));
|
.findByProjectAndUser(project, user)
|
||||||
|
.ifPresent(author ->
|
||||||
|
author.setSubscribedToFinalSeminarNotifications(
|
||||||
|
!author.isSubscribedToFinalSeminarNotifications()
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BooleanExpression unfinishedSeminars(Date after, Date before) {
|
private BooleanExpression unfinishedSeminars(Date after, Date before) {
|
||||||
QFinalSeminar seminar = QFinalSeminar.finalSeminar;
|
QFinalSeminar seminar = QFinalSeminar.finalSeminar;
|
||||||
if (after == null && before == null) {
|
if (after == null && before == null) {
|
||||||
return seminar.oppositions.any().grade.isNull().or(
|
return seminar.oppositions
|
||||||
seminar.activeParticipations.any().grade.isNull().or(
|
.any()
|
||||||
seminar.respondents.any().grade.isNull()));
|
.grade.isNull()
|
||||||
|
.or(
|
||||||
|
seminar.activeParticipations
|
||||||
|
.any()
|
||||||
|
.grade.isNull()
|
||||||
|
.or(seminar.respondents.any().grade.isNull())
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return seminar.startDate.between(after, before)
|
return seminar.startDate
|
||||||
.andAnyOf(seminar.oppositions.any().grade.isNull(),
|
.between(after, before)
|
||||||
seminar.activeParticipations.any().grade.isNull(),
|
.andAnyOf(
|
||||||
seminar.respondents.any().grade.isNull());
|
seminar.oppositions.any().grade.isNull(),
|
||||||
|
seminar.activeParticipations.any().grade.isNull(),
|
||||||
|
seminar.respondents.any().grade.isNull()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
@Table(name = "final_seminar_settings")
|
@Table(name = "final_seminar_settings")
|
||||||
public class FinalSeminarSettings extends DomainObject {
|
public class FinalSeminarSettings extends DomainObject {
|
||||||
|
|
||||||
public static final int DEFAULT_DAYS_AHEAD_TO_UPLOAD_THESIS = 10;
|
public static final int DEFAULT_DAYS_AHEAD_TO_UPLOAD_THESIS = 10;
|
||||||
public static final int DEFAULT_DAYS_AHEAD_TO_REGISTER_OPPOSITION = 3;
|
public static final int DEFAULT_DAYS_AHEAD_TO_REGISTER_OPPOSITION = 3;
|
||||||
public static final int DEFAULT_DAYS_AHEAD_TO_REGISTER_PARTICIPATION = 1;
|
public static final int DEFAULT_DAYS_AHEAD_TO_REGISTER_PARTICIPATION = 1;
|
||||||
@ -16,8 +16,7 @@ public class FinalSeminarSettings extends DomainObject {
|
|||||||
@Id
|
@Id
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
|
||||||
public FinalSeminarSettings() {
|
public FinalSeminarSettings() {}
|
||||||
}
|
|
||||||
|
|
||||||
public FinalSeminarSettings(final Long id) {
|
public FinalSeminarSettings(final Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -116,7 +115,25 @@ public class FinalSeminarSettings extends DomainObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FinalSeminarSettings(id=" + this.getId() + ", daysAheadToCreate=" + this.getDaysAheadToCreate() + ", daysAheadToRegisterParticipation=" + this.getDaysAheadToRegisterParticipation() + ", daysAheadToRegisterOpposition=" + this.getDaysAheadToRegisterOpposition() + ", daysAheadToUploadThesis=" + this.getDaysAheadToUploadThesis() + ", thesisMustBePDF=" + this.isThesisMustBePDF() + ", evaluationURL=" + this.getEvaluationURL() + ", oppositionPriorityDays=" + this.getOppositionPriorityDays() + ")";
|
return (
|
||||||
|
"FinalSeminarSettings(id=" +
|
||||||
|
this.getId() +
|
||||||
|
", daysAheadToCreate=" +
|
||||||
|
this.getDaysAheadToCreate() +
|
||||||
|
", daysAheadToRegisterParticipation=" +
|
||||||
|
this.getDaysAheadToRegisterParticipation() +
|
||||||
|
", daysAheadToRegisterOpposition=" +
|
||||||
|
this.getDaysAheadToRegisterOpposition() +
|
||||||
|
", daysAheadToUploadThesis=" +
|
||||||
|
this.getDaysAheadToUploadThesis() +
|
||||||
|
", thesisMustBePDF=" +
|
||||||
|
this.isThesisMustBePDF() +
|
||||||
|
", evaluationURL=" +
|
||||||
|
this.getEvaluationURL() +
|
||||||
|
", oppositionPriorityDays=" +
|
||||||
|
this.getOppositionPriorityDays() +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,16 +141,19 @@ public class FinalSeminarSettings extends DomainObject {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
if (!(o instanceof FinalSeminarSettings)) return false;
|
if (!(o instanceof FinalSeminarSettings)) return false;
|
||||||
final FinalSeminarSettings other = (FinalSeminarSettings) o;
|
final FinalSeminarSettings other = (FinalSeminarSettings) o;
|
||||||
return other.canEqual(this)
|
return (
|
||||||
&& super.equals(o)
|
other.canEqual(this) &&
|
||||||
&& Objects.equals(this.getId(), other.getId())
|
super.equals(o) &&
|
||||||
&& this.getDaysAheadToCreate() == other.getDaysAheadToCreate()
|
Objects.equals(this.getId(), other.getId()) &&
|
||||||
&& this.getDaysAheadToRegisterParticipation() == other.getDaysAheadToRegisterParticipation()
|
this.getDaysAheadToCreate() == other.getDaysAheadToCreate() &&
|
||||||
&& this.getDaysAheadToRegisterOpposition() == other.getDaysAheadToRegisterOpposition()
|
this.getDaysAheadToRegisterParticipation() ==
|
||||||
&& this.getDaysAheadToUploadThesis() == other.getDaysAheadToUploadThesis()
|
other.getDaysAheadToRegisterParticipation() &&
|
||||||
&& this.isThesisMustBePDF() == other.isThesisMustBePDF()
|
this.getDaysAheadToRegisterOpposition() == other.getDaysAheadToRegisterOpposition() &&
|
||||||
&& Objects.equals(this.getEvaluationURL(), other.getEvaluationURL())
|
this.getDaysAheadToUploadThesis() == other.getDaysAheadToUploadThesis() &&
|
||||||
&& this.getOppositionPriorityDays() == other.getOppositionPriorityDays();
|
this.isThesisMustBePDF() == other.isThesisMustBePDF() &&
|
||||||
|
Objects.equals(this.getEvaluationURL(), other.getEvaluationURL()) &&
|
||||||
|
this.getOppositionPriorityDays() == other.getOppositionPriorityDays()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
@ -143,13 +163,14 @@ public class FinalSeminarSettings extends DomainObject {
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
this.getId(),
|
this.getId(),
|
||||||
this.getDaysAheadToCreate(),
|
this.getDaysAheadToCreate(),
|
||||||
this.getDaysAheadToRegisterParticipation(),
|
this.getDaysAheadToRegisterParticipation(),
|
||||||
this.getDaysAheadToRegisterOpposition(),
|
this.getDaysAheadToRegisterOpposition(),
|
||||||
this.getDaysAheadToUploadThesis(),
|
this.getDaysAheadToUploadThesis(),
|
||||||
this.isThesisMustBePDF(),
|
this.isThesisMustBePDF(),
|
||||||
this.getEvaluationURL(),
|
this.getEvaluationURL(),
|
||||||
this.getOppositionPriorityDays());
|
this.getOppositionPriorityDays()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,30 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import se.su.dsv.scipro.system.AbstractServiceImpl;
|
||||||
|
|
||||||
public class FinalSeminarSettingsServiceImpl extends AbstractServiceImpl<FinalSeminarSettings,Long> implements FinalSeminarSettingsService {
|
public class FinalSeminarSettingsServiceImpl
|
||||||
|
extends AbstractServiceImpl<FinalSeminarSettings, Long>
|
||||||
|
implements FinalSeminarSettingsService {
|
||||||
|
|
||||||
private static final long INSTANCE_ID = 1L;
|
private static final long INSTANCE_ID = 1L;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarSettingsServiceImpl(Provider<EntityManager> em) {
|
public FinalSeminarSettingsServiceImpl(Provider<EntityManager> em) {
|
||||||
super(em, FinalSeminarSettings.class, QFinalSeminarSettings.finalSeminarSettings);
|
super(em, FinalSeminarSettings.class, QFinalSeminarSettings.finalSeminarSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public FinalSeminarSettings getInstance() {
|
public FinalSeminarSettings getInstance() {
|
||||||
FinalSeminarSettings settings = findOne(INSTANCE_ID);
|
FinalSeminarSettings settings = findOne(INSTANCE_ID);
|
||||||
if(settings==null) {
|
if (settings == null) {
|
||||||
settings = new FinalSeminarSettings(INSTANCE_ID);
|
settings = new FinalSeminarSettings(INSTANCE_ID);
|
||||||
save(settings);
|
save(settings);
|
||||||
}
|
}
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
public final class FinalSeminarThesisDeletedEvent {
|
public final class FinalSeminarThesisDeletedEvent {
|
||||||
|
|
||||||
private final FinalSeminar finalSeminar;
|
private final FinalSeminar finalSeminar;
|
||||||
|
|
||||||
public FinalSeminarThesisDeletedEvent(final FinalSeminar finalSeminar) {
|
public FinalSeminarThesisDeletedEvent(final FinalSeminar finalSeminar) {
|
||||||
|
@ -3,11 +3,12 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
|
||||||
public final class FinalSeminarThesisUploadedEvent {
|
public final class FinalSeminarThesisUploadedEvent {
|
||||||
|
|
||||||
private final FinalSeminar seminar;
|
private final FinalSeminar seminar;
|
||||||
|
|
||||||
public FinalSeminarThesisUploadedEvent(FinalSeminar seminar) {
|
public FinalSeminarThesisUploadedEvent(FinalSeminar seminar) {
|
||||||
this.seminar = seminar;
|
this.seminar = seminar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FinalSeminar getFinalSeminar() {
|
public FinalSeminar getFinalSeminar() {
|
||||||
return seminar;
|
return seminar;
|
||||||
|
@ -3,15 +3,13 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
import se.su.dsv.scipro.file.FileUpload;
|
import se.su.dsv.scipro.file.FileUpload;
|
||||||
|
|
||||||
public interface FinalSeminarUploadController {
|
public interface FinalSeminarUploadController {
|
||||||
|
|
||||||
enum SeminarDocumentUpload {
|
enum SeminarDocumentUpload {
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
ERROR_MUST_BE_PDF,
|
ERROR_MUST_BE_PDF,
|
||||||
ERROR_UPLOADER_MUST_BE_AUTHOR
|
ERROR_UPLOADER_MUST_BE_AUTHOR,
|
||||||
}
|
}
|
||||||
SeminarDocumentUpload storeSeminarDocument(
|
|
||||||
FileUpload fileUpload,
|
SeminarDocumentUpload storeSeminarDocument(FileUpload fileUpload, FinalSeminar seminar);
|
||||||
FinalSeminar seminar);
|
|
||||||
|
|
||||||
SeminarDocumentUpload replaceSeminarDocument(FinalSeminar finalSeminar, FileUpload fileUpload);
|
SeminarDocumentUpload replaceSeminarDocument(FinalSeminar finalSeminar, FileUpload fileUpload);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.util.Date;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import se.su.dsv.scipro.file.*;
|
import se.su.dsv.scipro.file.*;
|
||||||
@ -10,12 +12,11 @@ import se.su.dsv.scipro.project.Project;
|
|||||||
import se.su.dsv.scipro.project.ProjectService;
|
import se.su.dsv.scipro.project.ProjectService;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadController {
|
public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadController {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(FinalSeminarUploadControllerImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(
|
||||||
|
FinalSeminarUploadControllerImpl.class
|
||||||
|
);
|
||||||
|
|
||||||
private final FileService fileDescriptionService;
|
private final FileService fileDescriptionService;
|
||||||
private final FinalSeminarService finalSeminarService;
|
private final FinalSeminarService finalSeminarService;
|
||||||
@ -25,15 +26,16 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
|||||||
private final PlagiarismControl plagiarismControl;
|
private final PlagiarismControl plagiarismControl;
|
||||||
private final FinalSeminarSettingsService finalSeminarSettingsService;
|
private final FinalSeminarSettingsService finalSeminarSettingsService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FinalSeminarUploadControllerImpl(
|
public FinalSeminarUploadControllerImpl(
|
||||||
ProjectService projectService,
|
ProjectService projectService,
|
||||||
FileService fileDescriptionService,
|
FileService fileDescriptionService,
|
||||||
FinalSeminarSettingsService finalSeminarSettingsService,
|
FinalSeminarSettingsService finalSeminarSettingsService,
|
||||||
FinalSeminarService finalSeminarService,
|
FinalSeminarService finalSeminarService,
|
||||||
EventBus eventBus, ProjectFileService projectFileService,
|
EventBus eventBus,
|
||||||
final PlagiarismControl plagiarismControl)
|
ProjectFileService projectFileService,
|
||||||
{
|
final PlagiarismControl plagiarismControl
|
||||||
|
) {
|
||||||
this.projectService = projectService;
|
this.projectService = projectService;
|
||||||
this.fileDescriptionService = fileDescriptionService;
|
this.fileDescriptionService = fileDescriptionService;
|
||||||
this.finalSeminarSettingsService = finalSeminarSettingsService;
|
this.finalSeminarSettingsService = finalSeminarSettingsService;
|
||||||
@ -47,7 +49,7 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
|||||||
@Transactional
|
@Transactional
|
||||||
public SeminarDocumentUpload storeSeminarDocument(FileUpload fileUpload, FinalSeminar seminar) {
|
public SeminarDocumentUpload storeSeminarDocument(FileUpload fileUpload, FinalSeminar seminar) {
|
||||||
seminar = finalSeminarService.findOne(seminar.getId());
|
seminar = finalSeminarService.findOne(seminar.getId());
|
||||||
if (seminar.getDocument() != null){
|
if (seminar.getDocument() != null) {
|
||||||
throw new IllegalStateException("A file has already been uploaded");
|
throw new IllegalStateException("A file has already been uploaded");
|
||||||
}
|
}
|
||||||
return storeAndSetSeminarDocument(seminar, fileUpload);
|
return storeAndSetSeminarDocument(seminar, fileUpload);
|
||||||
@ -55,7 +57,10 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public SeminarDocumentUpload replaceSeminarDocument(final FinalSeminar finalSeminar, final FileUpload fileUpload) {
|
public SeminarDocumentUpload replaceSeminarDocument(
|
||||||
|
final FinalSeminar finalSeminar,
|
||||||
|
final FileUpload fileUpload
|
||||||
|
) {
|
||||||
if (finalSeminar.getDocument() != null) {
|
if (finalSeminar.getDocument() != null) {
|
||||||
// if someone else deletes the document while it is being replaced
|
// if someone else deletes the document while it is being replaced
|
||||||
fileDescriptionService.delete(finalSeminar.getDocument());
|
fileDescriptionService.delete(finalSeminar.getDocument());
|
||||||
@ -63,7 +68,10 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
|||||||
return storeAndSetSeminarDocument(finalSeminar, fileUpload);
|
return storeAndSetSeminarDocument(finalSeminar, fileUpload);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SeminarDocumentUpload storeAndSetSeminarDocument(final FinalSeminar finalSeminar, final FileUpload fileUpload) {
|
private SeminarDocumentUpload storeAndSetSeminarDocument(
|
||||||
|
final FinalSeminar finalSeminar,
|
||||||
|
final FileUpload fileUpload
|
||||||
|
) {
|
||||||
if (!assertParticipant(fileUpload.getUploader(), finalSeminar)) {
|
if (!assertParticipant(fileUpload.getUploader(), finalSeminar)) {
|
||||||
return SeminarDocumentUpload.ERROR_UPLOADER_MUST_BE_AUTHOR;
|
return SeminarDocumentUpload.ERROR_UPLOADER_MUST_BE_AUTHOR;
|
||||||
}
|
}
|
||||||
@ -73,7 +81,11 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
|||||||
|
|
||||||
final FileReference newDocument = fileDescriptionService.storeFile(fileUpload);
|
final FileReference newDocument = fileDescriptionService.storeFile(fileUpload);
|
||||||
setSeminarDocument(newDocument, finalSeminar);
|
setSeminarDocument(newDocument, finalSeminar);
|
||||||
projectFileService.promote(newDocument.getFileDescription(), finalSeminar.getProject(), FileSource.FINAL_SEMINAR);
|
projectFileService.promote(
|
||||||
|
newDocument.getFileDescription(),
|
||||||
|
finalSeminar.getProject(),
|
||||||
|
FileSource.FINAL_SEMINAR
|
||||||
|
);
|
||||||
return SeminarDocumentUpload.SUCCESS;
|
return SeminarDocumentUpload.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,9 +94,12 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
|||||||
seminar.setDocumentUploadDate(new Date());
|
seminar.setDocumentUploadDate(new Date());
|
||||||
|
|
||||||
seminar = finalSeminarService.save(seminar);
|
seminar = finalSeminarService.save(seminar);
|
||||||
plagiarismControl.submit(fileReference.getFileDescription(), seminar.getProject().getHeadSupervisor());
|
plagiarismControl.submit(
|
||||||
|
fileReference.getFileDescription(),
|
||||||
|
seminar.getProject().getHeadSupervisor()
|
||||||
|
);
|
||||||
|
|
||||||
eventBus.post(new FinalSeminarThesisUploadedEvent(seminar));
|
eventBus.post(new FinalSeminarThesisUploadedEvent(seminar));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean assertParticipant(final User uploader, final FinalSeminar seminar) {
|
private boolean assertParticipant(final User uploader, final FinalSeminar seminar) {
|
||||||
@ -102,10 +117,15 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
|||||||
private boolean assertMimeType(final String type) {
|
private boolean assertMimeType(final String type) {
|
||||||
final boolean requirePdf = finalSeminarSettingsService.getInstance().getThesisMustBePDF();
|
final boolean requirePdf = finalSeminarSettingsService.getInstance().getThesisMustBePDF();
|
||||||
if (type == null || (requirePdf && !type.equals("application/pdf"))) {
|
if (type == null || (requirePdf && !type.equals("application/pdf"))) {
|
||||||
LOGGER.debug("Faulty file type uploaded. Expected " + (requirePdf ? "\"application/pdf\"" : "non null") + ", was: \"" + type + "\"");
|
LOGGER.debug(
|
||||||
|
"Faulty file type uploaded. Expected " +
|
||||||
|
(requirePdf ? "\"application/pdf\"" : "non null") +
|
||||||
|
", was: \"" +
|
||||||
|
type +
|
||||||
|
"\""
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
package se.su.dsv.scipro.finalseminar;
|
package se.su.dsv.scipro.finalseminar;
|
||||||
|
|
||||||
public sealed interface MovingError extends SchedulingError permits NonWorkDay, NotEnoughWorkDays {
|
public sealed interface MovingError extends SchedulingError permits NonWorkDay, NotEnoughWorkDays {}
|
||||||
}
|
|
||||||
|
@ -2,5 +2,4 @@ package se.su.dsv.scipro.finalseminar;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
public record NonWorkDay(LocalDate date) implements MovingError {
|
public record NonWorkDay(LocalDate date) implements MovingError {}
|
||||||
}
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user