| 1 | package edu.ucsb.cs.scaffold.entity; | |
| 2 | ||
| 3 | import jakarta.persistence.*; | |
| 4 | import lombok.*; | |
| 5 | ||
| 6 | @Data | |
| 7 | @AllArgsConstructor | |
| 8 | @NoArgsConstructor | |
| 9 | @Builder | |
| 10 | @Entity | |
| 11 | @Table(name = "concepts") | |
| 12 | public class Concept { | |
| 13 | ||
| 14 | // Longest a top-level concept's label may be once its Markdown is rendered to plain text; | |
| 15 | // enforced everywhere labels enter the system (single-concept endpoints and YAML upload). | |
| 16 | // Top-level concepts are drawn as circular nodes on the concept graph, so their labels need | |
| 17 | // to stay short. | |
| 18 | public static final int MAX_RENDERED_LABEL_LENGTH = 32; | |
| 19 | ||
| 20 | // Longest a subconcept's label may be once its Markdown is rendered to plain text. Subconcepts | |
| 21 | // are listed as rows inside their parent's node (which wrap rather than needing to fit a | |
| 22 | // circle), so they can afford to be longer than top-level concept labels. | |
| 23 | public static final int MAX_RENDERED_SUBCONCEPT_LABEL_LENGTH = 60; | |
| 24 | ||
| 25 | @Id | |
| 26 | @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| 27 | private Long id; | |
| 28 | ||
| 29 | @ManyToOne | |
| 30 | @JoinColumn(name = "course_id", nullable = false) | |
| 31 | @ToString.Exclude | |
| 32 | private Course course; | |
| 33 | ||
| 34 | @Column(nullable = false) | |
| 35 | private String label; | |
| 36 | ||
| 37 | // length is set well above the default 255 so that Hibernate's schema | |
| 38 | // validation matches the VARCHAR(1048576) column defined in the migration. | |
| 39 | @Column(length = 1048576) | |
| 40 | private String description; | |
| 41 | ||
| 42 | @Column(length = 1048576) | |
| 43 | private String example; | |
| 44 | ||
| 45 | private String color; | |
| 46 | ||
| 47 | private Integer x; | |
| 48 | private Integer y; | |
| 49 | ||
| 50 | // Longest-path rank from a root (no-prerequisite) concept, 1-based. Top-level only, | |
| 51 | // recomputed by ConceptGraphService.reset(); see /api/course/scaffold/reset. | |
| 52 | private Integer level; | |
| 53 | ||
| 54 | // Author-chosen position of a subconcept within its parent's list, 0-based. Subconcepts | |
| 55 | // only (null for top-level concepts). Not unique: a concurrent create can leave two | |
| 56 | // subconcepts with the same value, which is harmless because display order always breaks | |
| 57 | // ties by id, and the next reorder rewrites the whole list to 0..n-1. | |
| 58 | private Integer sortOrder; | |
| 59 | ||
| 60 | @ManyToOne | |
| 61 | @JoinColumn(name = "parent_id") | |
| 62 | @ToString.Exclude | |
| 63 | private Concept parent; | |
| 64 | ||
| 65 | public boolean isSubconcept() { | |
| 66 |
2
1. isSubconcept : replaced boolean return with true for edu/ucsb/cs/scaffold/entity/Concept::isSubconcept → KILLED 2. isSubconcept : negated conditional → KILLED |
return parent != null; |
| 67 | } | |
| 68 | } | |
Mutations | ||
| 66 |
1.1 2.2 |