Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
Expand All @@ -12,13 +14,16 @@
* Models the enrollment of a user in a course
*/
@Data
@RequiredArgsConstructor
@AllArgsConstructor
@ApiModel(value = "AssignmentEnrollment", description = "Enrollment of a user in a assignment")
@Entity
@Table(name = "ASSIGNMENT_ENROLLMENT")
public class AssignmentEnrollment {

@Id
@Column(name = "ID")
@JsonIgnore
@GeneratedValue(generator = "sequence-generator")
@GenericGenerator(
name = "sequence-generator",
Expand All @@ -30,10 +35,10 @@ public class AssignmentEnrollment {
private int id;

// Assignment user is enrolled in
// @ApiModelProperty(value = "Enrolled assignment")
// @ManyToOne(fetch = FetchType.LAZY)
// @JoinColumn(name = "ASSIGNMENT_ID", referencedColumnName = "ID")
// private Assignment course;
@ApiModelProperty(value = "Enrolled assignment")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ASSIGNMENT_ID", referencedColumnName = "ID")
private Assignment assignment;

// User id
@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.unityTest.courseManagement.models.api.response.page;

import com.unityTest.courseManagement.entity.AssignmentEnrollment;
import io.swagger.annotations.ApiModel;
import org.springframework.data.domain.Page;

@ApiModel(value = "AssignmentEnrollmentPage", description = "Page request for enrollment of assignments")
public class AssignmentEnrollmentPage extends BasePage<AssignmentEnrollment> {
public AssignmentEnrollmentPage(Page<AssignmentEnrollment> page) {
super(page);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.unityTest.courseManagement.repository;

import com.unityTest.courseManagement.entity.AssignmentEnrollment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

@Repository
public interface AssignmentEnrollmentRepository
extends JpaRepository<AssignmentEnrollment, Integer>, JpaSpecificationExecutor<AssignmentEnrollment> {
}
13 changes: 13 additions & 0 deletions src/main/resources/db/h2/bootstrap_data.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

SET @USER_ID = 'TEST_ID';

INSERT INTO COURSE (ID, CODE, LEVEL, TERM, ACADEMIC_YEAR)
VALUES
(1, 'COMPSCI 1JC3', 1, 'FALL', 2019),
Expand Down Expand Up @@ -63,3 +66,13 @@ VALUES
(2, 'CASE', 1000, 'X02', 'How about being positive? :smile:', 0),

(3, 'CASE', 1001, 'X03', 'Should we have done this instead? `x = 3`?', 1);

INSERT INTO ASSIGNMENT_ENROLLMENT (ID, ASSIGNMENT_ID, USER_ID, PINNED)
VALUES
(1, 1, 'X01', false),
(2, 2, 'X02', false),
(3, 1, 'X02', true),
(4, 2, 'X01', true),
(5, 1, 'X03', false),
(6, 1, @USER_ID, false),
(7, 2, @USER_ID, true);